This is a WPF application.
Background:
I have a Wizard app. The wizard is initialized by providing a list of ViewModels. These ViewModels will create an appropriate view based on some DataTemplate in my XAML.
Clicking the next or previous one in the Wizard will install the corresponding ViewModel, and the view will be loaded based on the DataTemplate.
This works great.
Problem:
When I am in a transition state ... means that a new viewModel is loading, it looks like there is a short time when the previous VIEW is still referenced. Because of this, I get a bunch of BindingExpression errors where it says that it cannot find the binding binding that actually existed on the PREVIOUS viewModel.
SUMMARY: I am loading a new view based on a DataTemplate. When this view is initially loaded, it seems out of sync with the actual viewModel. This way I get a bunch of binding expression errors.
Two questions:
- Any thoughts on how to fix this?
Any danger of having these BindingExpression errors?
<wiz:WizardContent.Resources> <DataTemplate DataType="{x:Type viewModel:Step1ViewModel}"> <view:Step1 DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Path=DataContext.CurrentPageVM}"/> </DataTemplate> <DataTemplate DataType="{x:Type viewModel:Step2ViewModel}"> <view:Step2 DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Path=DataContext.CurrentPageVM}"/> </DataTemplate> <DataTemplate DataType="{x:Type viewModel:Step3ViewModel}"> <view:Step3 DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Path=DataContext.CurrentPageVM}"/> </DataTemplate> </wiz:WizardContent.Resources> <ContentControl Content="{Binding Path=CurrentPageVM}"/>
source share