FlyoutPresenter styles and templates

[ This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation ]

This topic describes the styles and templates for the FlyoutPresenter control. You can modify these resources and the default ControlTemplate to give the control a unique appearance.

Visual states

The FlyoutPresenter default style doesn't define any visual states.

Theme resources

These resources are used in the control's default style.

Dark theme brushes

To change the colors of the control in the dark theme, override these brushes in App.xaml.

<SolidColorBrush x:Key="FlyoutBackgroundThemeBrush" Color="#FF000000"/>
<SolidColorBrush x:Key="FlyoutBorderThemeBrush" Color="#FFFFFFFF"/>

Light theme brushes

To change the colors of the control in the light theme, override these brushes in App.xaml.

<SolidColorBrush x:Key="FlyoutBackgroundThemeBrush" Color="#FFFFFFFF"/>
<SolidColorBrush x:Key="FlyoutBorderThemeBrush" Color="#FF000000"/>

Other resources

<x:Double x:Key="FlyoutThemeMaxHeight">718</x:Double>
<x:Double x:Key="FlyoutThemeMaxWidth">450</x:Double>
<x:Double x:Key="FlyoutThemeMinHeight">54</x:Double>
<x:Double x:Key="FlyoutThemeMinWidth">70</x:Double>
<Thickness x:Key="FlyoutBorderThemeThickness">2</Thickness>
<Thickness x:Key="FlyoutContentThemePadding">20,17,20,20</Thickness>

For more info on theme resources, including the values that are used for the HighContrast theme, see XAML theme resources reference.

Default style

<!-- Default style for Windows.UI.Xaml.Controls.FlyoutPresenter -->
<Style TargetType="FlyoutPresenter">
    <Setter Property="RequestedTheme" Value="Light" />
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    <Setter Property="VerticalContentAlignment" Value="Stretch"/>
    <Setter Property="IsTabStop" Value="False"/>
    <Setter Property="Background" Value="{ThemeResource FlyoutBackgroundThemeBrush}"/>
    <Setter Property="BorderBrush" Value="{ThemeResource FlyoutBorderThemeBrush}"/>
    <Setter Property="BorderThickness" Value="{ThemeResource FlyoutBorderThemeThickness}"/>
    <Setter Property="Padding" Value="{ThemeResource FlyoutContentThemePadding}"/>
    <Setter Property="MinWidth" Value="{ThemeResource FlyoutThemeMinWidth}"/>
    <Setter Property="MaxWidth" Value="{ThemeResource FlyoutThemeMaxWidth}"/>
    <Setter Property="MinHeight" Value="{ThemeResource FlyoutThemeMinHeight}"/>
    <Setter Property="MaxHeight" Value="{ThemeResource FlyoutThemeMaxHeight}"/>
    <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto" />
    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
    <Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto" />
    <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
    <Setter Property="ScrollViewer.ZoomMode" Value="Disabled" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="FlyoutPresenter">
                <Border Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                    <ScrollViewer x:Name="ScrollViewer"
                        ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}"
                        HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                        HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                        VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                        VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                        AutomationProperties.AccessibilityView="Raw">
                        <ContentPresenter Content="{TemplateBinding Content}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          ContentTransitions="{TemplateBinding ContentTransitions}"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </ScrollViewer>
                </Border>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>