如何更改 Shell 弹出菜单的宽度/高度
How to change the width / height of Shell Flyout menu
我在我的 Xamarin Forms 应用程序中使用 Shell Flyoutmenu。一切都很好,除了我在菜单中的选项很短,托盘变得又宽又长。有没有办法改变 FlyoutMenu 的宽度和高度?我尝试将 WidthRequest
添加到 shell 对象本身以调整宽度,但它似乎没有什么不同。这是我的弹出窗口当前的样子。
这是 AppShell.xaml 文件内容
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:UniversalCheckInApp.Views"
x:Class="UniversalCheckInApp.AppShell"
BackgroundColor="#1E1F26"
FlyoutBackgroundColor="#D0E1F9">
<Shell.FlyoutHeader>
<StackLayout BackgroundColor="#1E1F26" Padding="4,4,4,4">
<Label Text="Navigation" TextColor="#D0E1F9" FontAttributes="Bold" HorizontalTextAlignment="Start"
VerticalTextAlignment="Center" FontSize="Large" Margin="4,4,4,4" />
</StackLayout>
</Shell.FlyoutHeader>
<Shell.ItemTemplate>
<DataTemplate>
<StackLayout HorizontalOptions="StartAndExpand" Padding="16,0,4,0" >
<Label Text="{Binding Title}" TextColor="#1E1F26" VerticalOptions="Center"
HorizontalOptions="Start" Margin="0,0,0,0" FontSize="Medium" FontAttributes="Bold"
TextDecorations="Underline"/>
</StackLayout>
</DataTemplate>
</Shell.ItemTemplate>
<FlyoutItem Title="Configuration" >
<ShellContent x:Name="scNetworkConfiguration" Title="Network Configuration" >
<views:NetworkConfiguration />
</ShellContent>
<ShellContent x:Name="scDataConfiguration" Title="Data Configuration">
<views:FormFieldConfiguration />
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Collect Data">
<ShellContent x:Name="scCollectData" Title="Collect Data">
<views:DataCollection />
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="About">
<ShellContent x:Name="scAbout" Title="About">
<views:About />
</ShellContent>
</FlyoutItem>
所以根据 MSFT 的 Elvis Xia 的评论 - 这是不可能的。我已经放弃在我的应用程序中使用 Shell 弹出菜单,所以我没有按照 Elvis 的建议打开 MSFT 的问题。如果这对其他人很重要,我建议您向 MSFT 提出问题,以便该功能可以包含在未来的版本中。
在 Xamarin.Forms 5.0.0.1829-pre6 上,两个附加属性 Shell.FlyoutWidth
和 Shell.FlyoutHeight
类型为 double have been added 允许设置 Shell 弹出窗口。
我在我的 Xamarin Forms 应用程序中使用 Shell Flyoutmenu。一切都很好,除了我在菜单中的选项很短,托盘变得又宽又长。有没有办法改变 FlyoutMenu 的宽度和高度?我尝试将 WidthRequest
添加到 shell 对象本身以调整宽度,但它似乎没有什么不同。这是我的弹出窗口当前的样子。
这是 AppShell.xaml 文件内容
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:UniversalCheckInApp.Views"
x:Class="UniversalCheckInApp.AppShell"
BackgroundColor="#1E1F26"
FlyoutBackgroundColor="#D0E1F9">
<Shell.FlyoutHeader>
<StackLayout BackgroundColor="#1E1F26" Padding="4,4,4,4">
<Label Text="Navigation" TextColor="#D0E1F9" FontAttributes="Bold" HorizontalTextAlignment="Start"
VerticalTextAlignment="Center" FontSize="Large" Margin="4,4,4,4" />
</StackLayout>
</Shell.FlyoutHeader>
<Shell.ItemTemplate>
<DataTemplate>
<StackLayout HorizontalOptions="StartAndExpand" Padding="16,0,4,0" >
<Label Text="{Binding Title}" TextColor="#1E1F26" VerticalOptions="Center"
HorizontalOptions="Start" Margin="0,0,0,0" FontSize="Medium" FontAttributes="Bold"
TextDecorations="Underline"/>
</StackLayout>
</DataTemplate>
</Shell.ItemTemplate>
<FlyoutItem Title="Configuration" >
<ShellContent x:Name="scNetworkConfiguration" Title="Network Configuration" >
<views:NetworkConfiguration />
</ShellContent>
<ShellContent x:Name="scDataConfiguration" Title="Data Configuration">
<views:FormFieldConfiguration />
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="Collect Data">
<ShellContent x:Name="scCollectData" Title="Collect Data">
<views:DataCollection />
</ShellContent>
</FlyoutItem>
<FlyoutItem Title="About">
<ShellContent x:Name="scAbout" Title="About">
<views:About />
</ShellContent>
</FlyoutItem>
所以根据 MSFT 的 Elvis Xia 的评论 - 这是不可能的。我已经放弃在我的应用程序中使用 Shell 弹出菜单,所以我没有按照 Elvis 的建议打开 MSFT 的问题。如果这对其他人很重要,我建议您向 MSFT 提出问题,以便该功能可以包含在未来的版本中。
在 Xamarin.Forms 5.0.0.1829-pre6 上,两个附加属性 Shell.FlyoutWidth
和 Shell.FlyoutHeight
类型为 double have been added 允许设置 Shell 弹出窗口。