I suspect that the elements of the application bar do not see the elements of the page, and therefore the binding of elements does not work. I would recommend that you use an independent property that implements the INotifyPropertyChanged interface. Bind this property to the elements for which you want to set visibility.
FROM#
public sealed partial class BlankPage4 : Page, INotifyPropertyChanged { private Visibility _IsHide; public Visibility IsHide { get { return _IsHide; } set { _IsHide = value; OnPropertyChanged("IsHide"); } } public BlankPage4() { this.InitializeComponent(); DataContext = this; } private void btnHideAll_Click(object sender, RoutedEventArgs e) { IsHide = Visibility.Collapsed; } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string property) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(property)); } } }
Xaml
<Page.BottomAppBar> <AppBar IsSticky="True" IsOpen="True"> <StackPanel Orientation="Horizontal"> <Button x:Name="btnHello" Visibility="{Binding IsHide}" Content="Hello" /> <TextBlock Visibility="{Binding IsHide}" Text="Hello" FontSize="20"/> </StackPanel> </AppBar> </Page.BottomAppBar> <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <StackPanel> <Button x:Name="btnSave" Visibility="{Binding IsHide}" Content="Save" /> <Button Content="Hide All" Click="btnHideAll_Click" /> </StackPanel> </Grid>
source share