Quantcast
Channel: User Liyun Zhang - MSFT - Stack Overflow
Viewing all articles
Browse latest Browse all 444

Answer by Liyun Zhang - MSFT for .Net MAUI Regions on screen

$
0
0

For the topbar you can use the Shell.TitleView. And for the rightbar, you can use the ContentPresenter and ControlTemplate.

Declare the ControlTemplate in the \Resources\Styles\Styles.xaml:

<ControlTemplate x:Key="rightbar"><Grid ColumnDefinitions="9*,1*" RowDefinitions="*,*,*"><ContentPresenter Grid.RowSpan="3" Grid.Column="0"/><Button Text="menu1" Grid.Row="0" Grid.Column="1"/><Button Text="menu2" Grid.Row="1" Grid.Column="1"/><Button Text="menu3" Grid.Row="2" Grid.Column="1"/></Grid></ControlTemplate>

Declare the Shell.TitleView in the AppShell.xaml:

<Shell.TitleView><Grid ColumnDefinitions="*,*,*,*"><Button Text="Menu1" Grid.Column="0"/><Button Text="Menu2" Grid.Column="1"/><Button Text="Menu3" Grid.Column="2"/><Button Text="Menu4" Grid.Column="3"/></Grid></Shell.TitleView><ShellContent        Title="Home"        ContentTemplate="{DataTemplate local:MainPage}"        Route="MainPage" />

And use the ControlTemplate in the Page:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"             ControlTemplate="{StaticResource rightbar}"             x:Class="MauiApp4.MainPage"><!--custom your page content in the contentpresenter--></ContentPage>

And the result image:

enter image description here

Of course, you can design the content of the bar by yourself.


Viewing all articles
Browse latest Browse all 444

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>