This project is read-only.

Reinitialize On Navigation

May 16, 2013 at 1:29 PM
Hello, I'm trying to find the best manner to keep my UI up to date with the DB.

Once the UserControl is loaded it stays into memory, is there a way to force the initialization every time the navigation to a usercontrol gets called.

May 16, 2013 at 1:49 PM
Edited May 16, 2013 at 1:54 PM
Seems I was a bit fast with my question, currently I found this solution:
public partial class MyView: UserControl, IContent
        public MyView()

        public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e)
            throw new NotImplementedException();

        public void OnNavigatedFrom(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
            // do nothing, dataconext already set to null
            // throw new NotImplementedException();

        public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
            DataContext = new MyViewModel();

        public void OnNavigatingFrom(FirstFloor.ModernUI.Windows.Navigation.NavigatingCancelEventArgs e)
            DataContext = null;
whether its a good one or a good approach is a different question :)
Jun 11, 2013 at 11:47 AM
Created the issue 19838 with this.
Jun 11, 2013 at 6:48 PM
Edited Jun 11, 2013 at 6:48 PM
You can decorate your page with the ModernFrame.KeepAlive=false attached property so that your content is created each time it's requested. See also this discussion
Jun 11, 2013 at 9:32 PM
What can I say!! Just beautiful! Got to see the source code to see more hidden beauties like this!! Having fun doing this!
Jun 12, 2013 at 9:11 AM
ModernFrame.KeepAlive=false makes it very short & nice, already implemented IContent but it does the job too :)