XAML .NET MAUI:删除弹出图标的空间

uxh89sit  于 2022-12-07  发布在  .NET
关注(0)|答案(1)|浏览(165)

在.NET MAUI中使用Flyouts时,每个项目旁边都有一个空格用于放置图标,但我不想使用图标。那么如何删除此空格呢?
下面是AppShell.xaml:

<?xml version="1.0" encoding="UTF-8" ?>
<Shell
    x:Class="TestApp.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:TestApp"
    Shell.FlyoutBehavior="{OnPlatform Android=Flyout, iOS=Flyout, MacCatalyst=Locked, Default=Locked}"
    Shell.FlyoutBackdrop="{AppThemeBinding Light=AliceBlue, Dark=DarkGray}"
    Shell.BackgroundColor="{AppThemeBinding Light=PaleTurquoise, Dark=#1f9e1c}"
    FlyoutBackgroundColor="{AppThemeBinding Dark=#0b1f0b}"
    Shell.FlyoutWidth="250">

    <FlyoutItem Title="Number 1">
        <ShellContent ContentTemplate="{DataTemplate local:Number1}" />
    </FlyoutItem>

    <FlyoutItem Title="Number2">
        <ShellContent ContentTemplate="{DataTemplate local:Number2}" />
    </FlyoutItem>

</Shell>

Here is an image

bfhwhh0e

bfhwhh0e1#

自订图标列样板

使用网格

<Shell.ItemTemplate>
    <DataTemplate>
        <Grid Margin="10,5" ColumnDefinitions="*" RowSpacing="20">
            <Label Text="{Binding Title}" FontAttributes="Bold"
                       FontSize="Medium" VerticalTextAlignment="Center"/>
        </Grid>
    </DataTemplate>
</Shell.ItemTemplate>

相关问题