I have this Property:
private string _TextBox1 = "Input";
public string TextBox1
{
get
{
return _TextBox1;
}
set
{
_TextBox1 = value;
NotifyPropertyChanged(nameof(TextBox1));
}
}
I placed it like that:
Text="{Binding TextBox1, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Now I type in some text and Change with that to next Page in my Project:
PagesNavigation.Navigate(new System.Uri("/EttiketPage.xaml", UriKind.RelativeOrAbsolute));
But now the Text I wrote get erased and the normal "Input" line is back.
What I have tried:
I know the ViewModel creates more then one Instance which it could be erased. To avoid that I created an ApplicationService class with that:
public sealed class ApplicationService
{
private ApplicationService() { }
public static ApplicationService Instance { get; } = new ApplicationService();
public ViewModel PrintView { get; } = new ViewModel();
}
And in every Page I placed this DataContext:
DataContext="{Binding PrintView, Source={x:Static local:ApplicationService.Instance}}"
But for some reason the data of the Property get erased every time I change the Page, someone an Idea?