How to call an empty UserControl with Uri from Link

May 20, 2013 at 4:56 AM
The issue is that I need to bring an empty UserControl every time I access to it.

The example of how I use this is:
ModernTab myTab = new ModernTab();
Link myLink = new Link();
Uri myUri = new Uri("Path/UserControl.xaml", UriKind.Relative);
myLink.DisplayName = "My New Link";
myLink.Source = myUri;
myTab.Links.Add(myLink);

But when I move to one user control and make some changes (i.e. add some text to an textBox) and move to another userControl, when I come back it has the same change, but I want that every time I acces to this userControl it be empty againg.

I tried to handle this with the GotFocus() property of the tab and set again the source to the link but it doesn't call againg the user control and mantain the data.

Thank you.
Coordinator
May 20, 2013 at 3:09 PM
Assign attached property ModernFrame.KeepAlive = false to your usercontrol XAML like so:
<UserControl .. 
    xmlns:mui="http://firstfloorsoftware.com/ModernUI"
    mui:ModernFrame.KeepAlive="false">
  ..
</UserControl>
May 21, 2013 at 2:46 AM
Problem solved.

Thank you :)