Dear all,
I'm building my solution using a Model view view model pattern.
My navigation should be proformed on my Viewmodel but I do not have any reference from the view model to the view (xaml page it self).
To perform my navigation I have a property (CurrentView) on my viemmodel and it is binded to the source property of my frame control on the view using something like:
<Controls:RadFrameContainer x:Name="MainFrameContainer" Background="{StaticResource Blue5}" Grid.Column="2" Grid.Row="1">
<Controls:RadFrame x:Name="MainFrame" Source="{Binding CurentView}"/>
</Controls:RadFrameContainer>
When I need to navigate I set the current view on my viewmodel to the desired page using something like:
protected void Navigate()
{
var viewtonavigate = new HomePage(); (1)
viewtonavigate.Parameter = "myparameter";
CurrentView = viewtonavigate;
}
public RadPage CurrentView
{
get{return currentview;}
set{
currentview = value;
RaisePropertyChange("CurrentView");(2)
}
}
My problem is that the constructor of the view HomePage is called twice.
Once on (1) and then (2) before being displayed on the frame.
and of course on the construction of (2) my Parameter is of course blank!!!
Do you have any idea why the page gets constructed a second time?
Thanks for your help.
Alex.
I'm building my solution using a Model view view model pattern.
My navigation should be proformed on my Viewmodel but I do not have any reference from the view model to the view (xaml page it self).
To perform my navigation I have a property (CurrentView) on my viemmodel and it is binded to the source property of my frame control on the view using something like:
<Controls:RadFrameContainer x:Name="MainFrameContainer" Background="{StaticResource Blue5}" Grid.Column="2" Grid.Row="1">
<Controls:RadFrame x:Name="MainFrame" Source="{Binding CurentView}"/>
</Controls:RadFrameContainer>
When I need to navigate I set the current view on my viewmodel to the desired page using something like:
protected void Navigate()
{
var viewtonavigate = new HomePage(); (1)
viewtonavigate.Parameter = "myparameter";
CurrentView = viewtonavigate;
}
public RadPage CurrentView
{
get{return currentview;}
set{
currentview = value;
RaisePropertyChange("CurrentView");(2)
}
}
My problem is that the constructor of the view HomePage is called twice.
Once on (1) and then (2) before being displayed on the frame.
and of course on the construction of (2) my Parameter is of course blank!!!
Do you have any idea why the page gets constructed a second time?
Thanks for your help.
Alex.