WPF, MVVM, and ComboBox: when changing to a different viewmodel, the ComboBox nulls the property bound to SelectedItem -
I have a window that uses data templates to display a different user control (view) based on the type of content content , Which is bound to a property that keeps the current view-model. In this way, by changing the Voodoo Property property with an event, I can require basic back / forward navigation.
When creating a new view-model, it is passed to a reference of the present. Going back to the old View-Model example works fine for checkbox control, but for single user control I have not included a text block and a combo box. The problem is, when the view containing the combo box is unloaded, the item of the combo box becomes the source faucet, which triggers it to clear its selected intestate / text property, which for some reason my view model It is limited to - so it becomes clear when I store data, I do not know how to manually share them at the right time (again, the checkbox works fine.)
I have read that other users have this exact same problem. For them, changing the item form and declaration of chosen eTema / text binding, so that the earlier issue could be corrected earlier. However, in my case, it is not. Others have fixed this issue by ignoring the zero / empty values, but it will not work in my case.
I will need to add interesting data by copying a different object and reloading it, but retaining data = to reload the data link = more code.
I can avoid using Datamatllet and manually add UserControls to CodeBeHind, which will allow me to break the data binding before deleting UserControl but it runs rival at the point of MVVM is.
I am not above the modification of my very non-MVVM UserControl to handle any event on the combo box to work around this issue.
Update: I have reduced this issue to a little bit, I have modified the code again, It has been created and added to view the view controller on which the view-modal has been set. The problem now only occurs when I view ViewControl to set the DataContext to zero. If I simply move the scene without removing the context, then the values of questions are not erased. Is this a useful solution, or does it create problems like memory leaks? Maybe something like that "open mind" for a simple solution ... if I I understand your problem, so it is similar to our previous problem. In our case, we have made the impression that it is not possible to empty a particular value when accessed by the Bald property, so we touched a fair ViewModel property: Using this kind of tweed properties, we call Not sure that this applies to your problem. UPDATE
Public MyItem SelectedItem {Return Model. My item; } Set up {if (value! = Null) {// and notify if not tap model. MyItem = value; OnPropertyChanged ("SelectedItem"); } Other // justify zero when trying to set OnPropertyChanged ("SelectedItem"); }}
null to call
OnPropertyChanged (..)
null , you will need to provide a different property that allows it.
Oh, I think that perhaps it describes the same method because "others have fixed the problem by ignoring the null / empty values" Which do not work in your case. But why should not I stop it?
Comments
Post a Comment