单击按钮时,按钮的可见性应在另一个页面中折叠 - UWP

When button click, the visibility of a button should be collapsed in another page - UWP

我正在制作一个 uwp 应用程序,在设置页面中,有一个左侧导航视图,当我转到外观部分并单击一个按钮时,另一个页面(MainPage)中的按钮应该是崩溃了,有办法吗?

When button click, the visibility of a button should be collapsed in another page - UWP

对于这种情况,您可以使用mvvmlight Messenger 来处理。而如果对方页面和发送页面不在同一个window。您需要在 xaml.

中设置其他页面 NavigationCacheMode="Required"

您要隐藏按钮的页面

public MainPage()
 {
     this.InitializeComponent(); 
     Messenger.Default.Register<bool>(this,(s) =>
     {
         if (s)
         {
             MyBtn.Visibility = Visibility.Collapsed;
         }
        
     });

 }

发送命令到上面页面的页面

private void Button_Click(object sender, RoutedEventArgs e)
 {
     Messenger.Default.Send<bool>(true);
 }