我想用c#设置菜单弹出窗口背景,因为我在运行时创建弹出窗口我该怎么做 我和xaml一样知道这个
<Flyout.FlyoutPresenterStyle>
<Style TargetType="FlyoutPresenter">
<Setter Property="ScrollViewer.ZoomMode" Value="Enabled"/>
<Setter Property="Background" Value="Black"/>
<Setter Property="BorderBrush" Value="Gray"/>
<Setter Property="BorderThickness" Value="5"/>
<Setter Property="MinHeight" Value="300"/>
<Setter Property="MinWidth" Value="300"/>
</Style>
</Flyout.FlyoutPresenterStyle>
如何使用c#实现此目的?
答案 0 :(得分:10)
终于解决了它
MenuFlyout m = new MenuFlyout();
Style s = new Windows.UI.Xaml.Style { TargetType = typeof(MenuFlyoutPresenter) };
s.Setters.Add(new Setter(BackgroundProperty,new SolidColorBrush(Colors.Blue)));
MenuFlyoutItem mn = new MenuFlyoutItem();
m.MenuFlyoutPresenterStyle = s;
m.Items.Add(mn);