c# - 在 Windows 8 中使用 C# 设置菜单 Flyout 背景颜色

标签 c# xaml windows-8.1

我想用 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# 实现这一点?

最佳答案

终于解决了

  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);

关于c# - 在 Windows 8 中使用 C# 设置菜单 Flyout 背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24040070/

相关文章:

c# - IQueryProvider 覆盖

wpf - 替换所有控件的前景色

windows-8 - WinJS getPrincipalNameAsync

c# - Windows Universal/Store App 中的类库本地化

c# - 检查当前日期时间是否在晚上 8 点到早上 8 点之间,并计算到早上 8 点之前剩余的总小时数

c# - 用于查看对象详细信息的 winforms 控件

c# - 如何在运行时向 ItemTemplate (Repeater) 添加控件?

c# - 如何使我的按钮网格适合 WPF-XAML 中的六边形图像

WPF XAML ListView - 使 TextBlock 文本换行

.net - 如何在 Windows 8.1 中安装 WPF 性能套件?