When Navigating the ViewModel Contructor Keeps Instantiating.....

Sep 7, 2014 at 3:07 AM
Edited Sep 7, 2014 at 3:19 AM
Hi,

When checking to see of my ViewModels are instantiating I also notice when Navigating to and from Views the Contructor keeps instantiating. How to I keep this from doing this. I would like it to be a ControlledLifetime state.

testing my navigation like this:
<prism:VisualStateAwarePage.BottomAppBar>
    <AppBar>
        <Grid>
            <StackPanel x:Name="RightPanel" Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right">
                <AppBarButton x:Uid="Remove" Icon="Remove" Label="Remove">
                    <Interactivity:Interaction.Behaviors>
                        <Core:EventTriggerBehavior EventName="Click">
                            <Core:NavigateToPageAction TargetPage="NathsarTS.HebrewWritings.Views.HebrewPage" Parameter="IgnoredParameter"/>
                        </Core:EventTriggerBehavior>
                    </Interactivity:Interaction.Behaviors>
                </AppBarButton>
            </StackPanel>
        </Grid>
    </AppBar>
</prism:VisualStateAwarePage.BottomAppBar>
return like this:
<AppBarButton x:Name="Back" Icon="Back" Margin="20,55,0,0" Command="{Binding GoBackCommand, ElementName=hebrewPageRoot}"/>
Thanks!...
Sep 7, 2014 at 4:00 AM
Cancel that!... I just registered them to the container.
_container.RegisterType<NathsarTS.UILogic.ViewModels.MainPageViewModel>(new ContainerControlledLifetimeManager());
_container.RegisterType<NathsarTS.UILogic.ViewModels.HebrewPageViewModel>(new ContainerControlledLifetimeManager());