Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Menu Flyout background color using c# in windows 8

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#?

like image 919
user3090763 Avatar asked Jun 04 '14 14:06

user3090763


1 Answers

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);
like image 106
user3090763 Avatar answered Nov 05 '22 04:11

user3090763