I want to set menu flyout background with c# because I am creating flyout at runtime how can I do that I know this with xaml like this
<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>
How to achieve this using c#?
Finally solved it
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With