Can MVVM Usercontrols have a property defined in codebehind?

I have a WPF user control ... which is in MVVM. A user control (which contains a list) needs data from the page (where it is included). I have to set a property to enter this data. Would this be consistent with MVVM ... if not, then what is the way to that?

+3
source share
2 answers

I am afraid that this will not be correct in the MVVM design pattern. try sticking to your view model to define properties. Why don't you consider moving this property to control vm?

+1

ObservableCollection .

ObservableCollection<myModel> myOC = new ObservableCollection<myModel>();

myModel - , , DataTable .

MainViewModel DataReader myOC.

myOC ListView .

DataTemplate ListView (UserControl) ViewModel, myModel

UserControl ListView . , , .

+1

Source: https://habr.com/ru/post/1746827/


All Articles