Access and set ViewModel property in common class in WPF application RRS feed

  • Question

  • Hello All,

    I have a viewmodel PersonViewModel in WPF application and this viewmodel contains LstRequests property:

            public List<PersonRequest> LstRequests
                get { return lstRequests; }
                set { RaisePropertyChanged("LstRequests"); }

    Now I have a separate Utility class in this project and in this Utility class I have a method where I need to set LstRequests property of current running instance of viewmodel PersonViewModel. 

    Please help in achieving this ASAP. Many thanks in advance.



    Saturday, June 15, 2019 6:47 PM

All replies

  • Hi,
    your Utility class doesn't know your ViewModel. The ViewModel get the LstRequest from the Utilitiy.

            public List<PersonRequest> LstRequests
                get { return Utility.GetLstRequests(); }

    Best Regards / Viele Grüße
    Peter Fleischer (former MVP for Developer Technologies)
    Homepage, Tipps, Tricks

    Saturday, June 15, 2019 7:13 PM