Defina a cor de fundo do Menu Flyout usando c # no Windows 8
-
21-12-2019 - |
Pergunta
Eu quero definir o fundo do menu Flyout com C# porque estou criando flyout no tempo de execução, como posso fazer o que sei disso com xaml assim
<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>
Como conseguir isso usando c#?
Solução
Finalmente resolvi
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);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow