I thought I was right from Josh Smith's MVVM manual but I have many problems
So, I have a ContentControl
as defined in XML:
& lt; Content Control Grid Raw = "0" content = "{binding currentview module}" />
This is a resource in the ContentControl
window that looks something like this:
& lt; ResourceDictionary ... & gt; ; & Lt; DataTemplate DataType = "{x: Type lib_vm: SetupPanelViewModel}" & gt; & Lt; Lib_v: setuppanel / & gt; & Lt; / DataTemplate & gt; & Lt; DataTimeplate DataType = "{x: Type lib_vm: Directives PanelViewModel}" & gt; & Lt; Lib_v: directpanel / & gt; & Lt; / DataTemplate & gt; & Lt; / ResourceDictionary & gt;
Therefore, basically, two data templates specify which view-to-display with the model.
This is the property on CurrentViewModel
my window's view-model change, but it also seems that value converters may be seen in the fire even when no data is changed. Could. This is a special problem with IMultiValueConverter
classes, because the value of the value
array is set to DependencyProperty.UnsetValue
, which causes exceptions. As long as I do not specifically check for him. But I'm getting other strange side effects too.
It is thinking that I should not do everything manually, like this:
- Instant each view.
- Set
DataContext
of each view of the appropriate visual model. - Name
ContentControl and make it public - Hold
property by changing
event for the window. - In the event handler, manually set
content
toproperty>
oncontrol CurrentViewModel ( If
by using the statement) in the appropriate view.
It seems to work, but it looks very strange. I'm hoping that there is a better way.
Could you please advise the best way to handle switching so that price converters do not fire unnecessarily?
You should look at PRISM or any other composite UI framework. Prism will give you a great mechanism for this type of thing.
Comments
Post a Comment