Xaml 更改弹出按钮(UWP)的背景色
我的页面上有一个弹出控件,我想更改它的背景色。我怎样才能做到这一点Xaml 更改弹出按钮(UWP)的背景色,xaml,uwp,uwp-xaml,Xaml,Uwp,Uwp Xaml,我的页面上有一个弹出控件,我想更改它的背景色。我怎样才能做到这一点 <Button x:Name="btn" Background="Transparent"> <Image HorizontalAlignment="Center" /> <Button.Flyout > <Flyout Placement="Left" >
<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>
若我为子元素提供背景,它会在弹出型按钮和子元素之间提供一个边距,所以这是不可接受的。现在看起来像这样
要更改弹出型按钮的背景色,可以尝试设置显示弹出型按钮内容的内部按钮的属性样式。例如:
<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>
您需要一个自定义菜单OutPresenterStyle;参见上的示例