【发布时间】:2018-07-12 07:00:38
【问题描述】:
我想知道如何将可重复使用的浮动菜单添加到 xamarin 应用程序的所有页面?
我们是否可以选择在 xamarin 中创建母版页布局并添加部分视图?
例如,在下面的模板中,我想在所有页面中重复以下 stacklayout 部分。
在页面上我有关注
<ContentPage.Content>
<ScrollView>
<StackLayout BackgroundColor="MediumPurple" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" >
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand" BackgroundColor="White">
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" >
<Button Text="All" Clicked="PromoAll_Clicked" BackgroundColor="Orange" />
</StackLayout>
</StackLayout>
<Label Text="Upcoming Events" VerticalTextAlignment="Center" FontSize="Large" TextColor="White" HorizontalOptions="Center" />
<ListView x:Name="PromolistView" ItemTapped="promoOnItemSelected" RowHeight="55" BackgroundColor="MediumPurple" HasUnevenRows="True" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
....
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
// this area needs to be repeated every page
<StackLayout Orientation="Horizontal" VerticalOptions="End">
<Button Text="A" FontAttributes="Bold" BackgroundColor="MediumSlateBlue" BorderRadius="50" TextColor="White"></Button>
<Button Text="B" FontAttributes="Bold" BackgroundColor="MediumSlateBlue" TextColor="White"></Button>
</StackLayout>
//end of the floating menu
</StackLayout>
</ScrollView>
</ContentPage.Content>
【问题讨论】: