The purpose of building the application bar is to display navigation, commands, and tools that always hide unwanted use. We can place the application bar at the top or bottom of the page or at the top and bottom.
The default is hidden in AppBar and can be displayed or closed when the user clicks the right button, presses the win+z, or is relaxed from the top or bottom edge of the screen. AppBar Of course, we can also programmatically set the AppBar to display when the user makes a selection or interacts with the application.
Basic Steps for building AppBar
Usually we build an application AppBar that takes only three steps to complete:
How to build AppBar
Add AppBar to the application, you need to assign the AppBar control to the Topappbar or Bottomappbar property of the page.
The XAML code can be as follows:
<Page.BottomAppBar> <appbar x:name= "Bottomappbar" padding= "10,0,10,0" >
<Grid> <stackpanel orientation= "horizontal" horizontalalignment= "left" > <button style= "{StaticResource Editappbarbuttonstyle}"/> ; Button style= ' {StaticResource removeappbarbuttonstyle} '/> <button style= ' {Staticreso Urce Addappbarbuttonstyle} "/> </StackPanel> <stackpanel orientation= "Horizontal" horizontalalignment= "right" > <button style= "{StaticResource Refreshappbarbuttonstyle} "/> <button style=" {StaticResource Helpappbarbuttonstyle} " /> </StackPanel> </Grid> </appbar&
Gt </pagE.bottomappbar>
Resource styles referenced in XAML code can be found in Standardstyles.xaml files in the common folder of the application solution.
Operation Effect:
If we want to open appbar when the page is loaded, you can set the IsOpen property value of the AppBar control to True in XAML code, or you can control the open AppBar in C # code.
private void Openbutton_click (object sender,
RoutedEventArgs e)
{
Topappbar.isopen = true;
}
When the user interacts anywhere other than the applied AppBar, the default is AppBar hidden. We can change the release mode by setting the Issticky property value to True.
The user only hides the AppBar when it is right-click, press Win+z, or swipe from the top or bottom edge of the screen.
private void Stickybutton_click (object
sender, RoutedEventArgs e)
{
bottomappbar.issticky = true;
}