Such a moment, I am writing an application for Windows Phone, I need to transfer data from one page to another, Frame and OnNavigateonTO use no features, I need to through PropertyChanged. My own problem is that PropertyChanged does not notice the change in Enter and does not update the data in the MainPage; I actually need to transfer them to this page ... when the change occurs on the Enter page, they go to the MenuItem class, but the value does not change MainPage page

!!!!!!!! MainPage.xaml.cs

...<TextBlock x:Name="NameWorker" Text="{x:Bind demomenuViewModel.Welcom, Mode=OneWay}" />.... public sealed partial class MainPage : Page { demomenuViewModel demomenuViewModel = new demomenuViewModel(); .... 

!!!!!! Enter.xaml.cs

  public sealed partial class Enter : Page { private demomenuViewModel VM = new demomenuViewModel(); private void enter_Click(object sender, RoutedEventArgs e) { VM.Welcom = login.nameuser.ToString(); } ... } 

!!! MenuItem.cs

 public class demomenuViewModel : asyncViewModel { ... public string Welcom { get { return welcom; } set { welcom = value; INotifyPropertyChanged(); } } ... } 
  • Remove all unnecessary code, and demonstrate the problem with a complete example. The minimum reproducible example is VladD
  • @VladD so clearer? - Denis Krovyakov
  • Okay, but what is not clear? You have two different instances of demomenuViewModel , it is clear that the data in them is in no way connected. - VladD
  • Yes, I already understood this, I tried to do it through ' statik ', it also did not work out, because the function ' INotifyPropertyChanged ' does not work as static .... Perhaps you can suggest some ideas? - Denis Krovyakov
  • For example, feed the pages ( MainPage and Enter ) the same demomenuViewModel instance in the constructor? - VladD

0