This can be approached in XAML using datatemplates and / or triggers. For example, if each page in your wizard was presented in the base model as a separate class or object, you can use one of the following two parameters ... Both use ContentControl, which is an ideal control when the content changes significantly between different representations of the same data.
Please note that bindings are intended as examples of pseudocode to convey intent!
Based on a DataTemplate using different classes for each page:
<Grid> <Grid.Resources> <DataTemplate DataType="{x:Type WizardPageOne}"> </DataTemplate> <DataTemplate DataType="{x:Type WizardPageTwo}"> </DataTemplate> </Grid.Resources> <ContentControl Content="{Binding CurrentPageModel, Source=Wizardmodel}" /> </Grid>
Or Based on a trigger using a property that indicates the current page:
<ContentControl Content="{Binding WizardModel}"> <ContentControl.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding CurrentPageIndex} Value="1"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> </ControlTemplate> </Setter.Value> </Setter> </DataTrigger> <DataTrigger Binding="{Binding CurrentPageIndex} Value="2"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> </ControlTemplate> </Setter.Value> </Setter> </DataTrigger> </Style.Triggers> </Style> </ContentControl.Style> </ContentControl>
Both options will only load the control for each page, as required, so you do not have all the controls loaded but hidden in the window.
source share