【问题标题】:Change Background color of flyout (UWP)更改浮出控件的背景颜色 (UWP)
【发布时间】:2020-08-28 14:15:44
【问题描述】:

我的页面上有一个 Flyout 控件,我想更改它的背景颜色。我怎样才能做到这一点?

 <Button x:Name="btn"  Background="Transparent">
            <Image HorizontalAlignment="Center" />
            <Button.Flyout  >
                <Flyout Placement="Left" >
                    <ListView  ItemsSource="{x:Bind DDLItemsSource, Mode=OneWay}" Background="Green" VerticalAlignment="Stretch"  
                               SelectionChanged="StudentsList_SelectionChanged" x:Name="StudentsList" SelectionMode="Extended"  HorizontalAlignment="Stretch"  >
                        <Style TargetType="ListViewItem">
                            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                        </Style>
                    </ListView>
                </Flyout>
            </Button.Flyout>
        </Button>

如果我给子元素背景,它会在弹出和子元素之间留出一个边距,所以这是不可接受的。目前看起来像这样

【问题讨论】:

标签: xaml uwp uwp-xaml


【解决方案1】:

要更改 Flyout 的背景颜色,您可以尝试设置呈现 Flyout 内容的内部FlyoutPresenter 的属性的样式。例如:

<Button.Flyout>
    <Flyout Placement="Left">

        <Flyout.FlyoutPresenterStyle>
            <Style TargetType="FlyoutPresenter">
                <Setter Property="Background" Value="Green"/>
            </Style>
        </Flyout.FlyoutPresenterStyle>

        <ListView ItemsSource="{x:Bind DDLItemsSource, Mode=OneWay}" Background="Green" VerticalAlignment="Stretch"  SelectionChanged="StudentsList_SelectionChanged" x:Name="StudentsList" SelectionMode="Extended"  HorizontalAlignment="Stretch"  >
            <Style TargetType="ListViewItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            </Style>
        </ListView>
    </Flyout>
</Button.Flyout>

【讨论】:

    猜你喜欢
    • 2016-07-04
    • 2019-12-22
    • 1970-01-01
    • 1970-01-01
    • 2011-11-22
    • 1970-01-01
    • 2017-11-02
    • 2018-02-04
    • 2020-03-01
    相关资源
    最近更新 更多