I want to hide the button in my AppBar from the HubSections i have been using the following codes but it does not work please help i have just started with c# im new to it. Thanks

HubPage.xaml
<Page.BottomAppBar> <CommandBar x:Name="mybar" ClosedDisplayMode="Minimal"  > <CommandBar.SecondaryCommands> <AppBarButton Label="setting" Click="AppBarButton_Click"/> </CommandBar.SecondaryCommands> <AppBarButton x:Uid="CALENDAR" Label="calendar" Click="AppBarButton_Click"> <AppBarButton.Icon> <SymbolIcon x:Name="btnCalendar" Symbol="Calendar"/> </AppBarButton.Icon> </AppBarButton> <AppBarButton x:Name="btnLocation" x:Uid="MAP" Icon="MapPin" Label="location" Click="AppBarButton_Click"  /> </CommandBar> </Page.BottomAppBar> <Page.Resources>

    HubPage.xaml.cs
    private void Hub_SectionsInViewChanged(object sender, SectionsInViewChangedEventArgs e)
        {
            try
            {


                switch (MyHub.SectionsInView[0].Name)
                {
                    case "HubSection0":
                        btnCalendar.Visibility = Visibility.Visible;
                        btnLocation.Visibility = Visibility.Visible;
                        break;
                    case "HubSection1":
                        btnCalendar.Visibility = Visibility.Collapsed;
                        btnLocation.Visibility = Visibility.Visible;
                        break;

                    case "HubSection2":
                     btnCalendar.Visibility = Visibility.Collapsed;
                        btnLocation.Visibility = Visibility.Collapsed;
                        break;
                    case "HubSection3":
                          btnCalendar.Visibility = Visibility.Collapsed;
                        btnLocation.Visibility = Visibility.Collapsed;
                        break;
                    default:
                        return;
                }


            }
            finally
            {

            }

        }

From memory. It's been a few years since I released some WM apps. That doesn't take effect on forms that are already displayed. You have to refresh the form/display.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.