none
Création de VisualStates dans Blend RRS feed

  • Question

  • Bonjour, dans Blend j'ai affecté un élément VisualState à un TextBlock.

    J'aimerais pouvoir transférer ce code dans App.xaml afin qu'il s'applique à tous les TextBlock.

    Voici le code :

     <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="VisualStateGroup">
                    <VisualState x:Name="On">
                        <Storyboard>
                            <ColorAnimation Duration="0" To="#FF1F6E42" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                            Storyboard.TargetName="QuitApp" d:IsOptimized="True"/>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="Off"/>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>

      <TextBlock x:Name="QuitApp" RelativePanel.RightOf="Sep"
                           Text="&#xE726;"
                           Tapped="QuitApp_Tapped"
                           Style="{StaticResource TBMDL2Assets}">
                    <Interactivity:Interaction.Behaviors>
                        <Core:EventTriggerBehavior EventName="PointerEntered">
                            <Core:GoToStateAction StateName="On"/>
                        </Core:EventTriggerBehavior>
                        <Core:EventTriggerBehavior EventName="PointerExited">
                            <Core:GoToStateAction StateName="Off"/>
                        </Core:EventTriggerBehavior>
                    </Interactivity:Interaction.Behaviors>
                </TextBlock>


    JF Collombet ® CreateSpecificCulture

    vendredi 3 février 2017 10:39

Réponses

  • Bonjour,

    En fait si j'ai bien compris, ce que vous souhaitez faire c'est de créer un style qui s'appliquera par défaut à toutes les texbox de votre application.

    Si je me permets de vous dire ça c'est qu'en fait le VisualStateManager fait parti du style des contrôles.

    Donc ce que je vous propose, c'est de créer un style qui target vers une texbox et ensuite dans le style mettre votre VisualStateManager.

    Voici un exemple en appliquant votre VisualStateManager à mettre dans votre fichier App.xaml : 

                <!-- Default style for Windows.UI.Xaml.Controls.TextBox -->
                <Style TargetType="TextBox" >
                    <Setter Property="MinWidth"
                            Value="{ThemeResource TextControlThemeMinWidth}" />
                    <Setter Property="MinHeight"
                            Value="{ThemeResource TextControlThemeMinHeight}" />
                    <Setter Property="Foreground"
                            Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
                    <Setter Property="Background"
                            Value="{ThemeResource SystemControlBackgroundAltHighBrush}" />
                    <Setter Property="BorderBrush"
                            Value="{ThemeResource SystemControlForegroundChromeDisabledLowBrush}" />
                    <Setter Property="SelectionHighlightColor"
                            Value="{ThemeResource SystemControlHighlightAccentBrush}" />
                    <Setter Property="BorderThickness"
                            Value="{ThemeResource TextControlBorderThemeThickness}" />
                    <Setter Property="FontFamily"
                            Value="{ThemeResource ContentControlThemeFontFamily}" />
                    <Setter Property="FontSize"
                            Value="{ThemeResource ControlContentThemeFontSize}" />
                    <Setter Property="ScrollViewer.HorizontalScrollMode"
                            Value="Auto" />
                    <Setter Property="ScrollViewer.VerticalScrollMode"
                            Value="Auto" />
                    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
                            Value="Hidden" />
                    <Setter Property="ScrollViewer.VerticalScrollBarVisibility"
                            Value="Hidden" />
                    <Setter Property="ScrollViewer.IsDeferredScrollingEnabled"
                            Value="False" />
                    <Setter Property="Padding"
                            Value="{ThemeResource TextControlThemePadding}" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="TextBox">
                                <Grid>
                                    <Grid.Resources>
                                        <Style x:Name="DeleteButtonStyle"
                                               TargetType="Button">
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="Button">
                                                        <Grid x:Name="ButtonLayoutGrid"
                                                              BorderBrush="{ThemeResource TextBoxButtonBorderThemeBrush}"
                                                              BorderThickness="{TemplateBinding BorderThickness}"
                                                              Background="{ThemeResource TextBoxButtonBackgroundThemeBrush}">
                                                            <VisualStateManager.VisualStateGroups>
                                                                <VisualStateGroup x:Name="CommonStates">
                                                                    <VisualState x:Name="Normal" />
                                                                    <VisualState x:Name="PointerOver">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
                                                                                                           Storyboard.TargetProperty="Foreground">
                                                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                                                        Value="{ThemeResource SystemControlHighlightAccentBrush}" />
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Pressed">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid"
                                                                                                           Storyboard.TargetProperty="Background">
                                                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                                                        Value="{ThemeResource SystemControlHighlightAccentBrush}" />
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
                                                                                                           Storyboard.TargetProperty="Foreground">
                                                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                                                        Value="{ThemeResource SystemControlHighlightAltChromeWhiteBrush}" />
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Disabled">
                                                                        <Storyboard>
                                                                            <DoubleAnimation Storyboard.TargetName="ButtonLayoutGrid"
                                                                                             Storyboard.TargetProperty="Opacity"
                                                                                             To="0"
                                                                                             Duration="0" />
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                </VisualStateGroup>
                                                            </VisualStateManager.VisualStateGroups>
                                                            <TextBlock x:Name="GlyphElement"
                                                                       Foreground="{ThemeResource SystemControlForegroundChromeBlackMediumBrush}"
                                                                       VerticalAlignment="Center"
                                                                       HorizontalAlignment="Center"
                                                                       FontStyle="Normal"
                                                                       FontSize="12"
                                                                       Text="&#xE10A;"
                                                                       FontFamily="{ThemeResource SymbolThemeFontFamily}"
                                                                       AutomationProperties.AccessibilityView="Raw" />
                                                        </Grid>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </Grid.Resources>
                                    
                                    <!--VOTRE VISUAL STATE MANAGER-->
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="VisualStateGroup">
                                            <VisualState x:Name="On">
                                                <Storyboard>
                                                    <ColorAnimation Duration="0"
                                                                    To="#FF1F6E42"
                                                                    Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                                                    Storyboard.TargetName="QuitApp"
                                                                    d:IsOptimized="True" />
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Off" />
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <Border x:Name="BackgroundElement"
                                            Grid.Row="1"
                                            Background="{TemplateBinding Background}"
                                            Margin="{TemplateBinding BorderThickness}"
                                            Opacity="{ThemeResource TextControlBackgroundRestOpacity}"
                                            Grid.ColumnSpan="2"
                                            Grid.RowSpan="1" />
                                    <Border x:Name="BorderElement"
                                            Grid.Row="1"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="{TemplateBinding BorderThickness}"
                                            Grid.ColumnSpan="2"
                                            Grid.RowSpan="1" />
                                    <ContentPresenter x:Name="HeaderContentPresenter"
                                                      x:DeferLoadStrategy="Lazy"
                                                      Visibility="Collapsed"
                                                      Grid.Row="0"
                                                      Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
                                                      Margin="0,0,0,8"
                                                      Grid.ColumnSpan="2"
                                                      Content="{TemplateBinding Header}"
                                                      ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                      FontWeight="Normal" />
                                    <ScrollViewer x:Name="ContentElement"
                                                  Grid.Row="1"
                                                  HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                                                  HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                                                  VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                                                  VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                                                  IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
                                                  IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
                                                  IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
                                                  Margin="{TemplateBinding BorderThickness}"
                                                  Padding="{TemplateBinding Padding}"
                                                  IsTabStop="False"
                                                  AutomationProperties.AccessibilityView="Raw"
                                                  ZoomMode="Disabled" />
                                    <ContentControl x:Name="PlaceholderTextContentPresenter"
                                                    Grid.Row="1"
                                                    Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
                                                    Margin="{TemplateBinding BorderThickness}"
                                                    Padding="{TemplateBinding Padding}"
                                                    IsTabStop="False"
                                                    Grid.ColumnSpan="2"
                                                    Content="{TemplateBinding PlaceholderText}"
                                                    IsHitTestVisible="False" />
                                    <Button x:Name="DeleteButton"
                                            Grid.Row="1"
                                            Style="{StaticResource DeleteButtonStyle}"
                                            BorderThickness="{TemplateBinding BorderThickness}"
                                            Margin="{ThemeResource HelperButtonThemePadding}"
                                            IsTabStop="False"
                                            Grid.Column="1"
                                            Visibility="Collapsed"
                                            FontSize="{TemplateBinding FontSize}"
                                            MinWidth="34"
                                            VerticalAlignment="Stretch" />
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>

    A noter que votre fichier App.xaml doit contenir vos ressources à cette emplacement : 

    <Application
        x:Class="MSDNSample.App"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:SpiderMSDN">
        <Application.Resources>
    
           <!--INSEREZ VOTRE STYLE ICI -->
    
        </Application.Resources>
    
    </Application>

    J'espère que j'ai bien répondu à votre question.

    Si c'est le cas, n'hésitez pas à mettre ma réponse en réponse à votre post

    Vous pouvez me suivre sur Twitter : https://twitter.com/NordineMhoumadi


    My blog : https://nordinemhoumadi.wordpress.com/

    vendredi 3 février 2017 13:07

Toutes les réponses

  • Bonjour,

    En fait si j'ai bien compris, ce que vous souhaitez faire c'est de créer un style qui s'appliquera par défaut à toutes les texbox de votre application.

    Si je me permets de vous dire ça c'est qu'en fait le VisualStateManager fait parti du style des contrôles.

    Donc ce que je vous propose, c'est de créer un style qui target vers une texbox et ensuite dans le style mettre votre VisualStateManager.

    Voici un exemple en appliquant votre VisualStateManager à mettre dans votre fichier App.xaml : 

                <!-- Default style for Windows.UI.Xaml.Controls.TextBox -->
                <Style TargetType="TextBox" >
                    <Setter Property="MinWidth"
                            Value="{ThemeResource TextControlThemeMinWidth}" />
                    <Setter Property="MinHeight"
                            Value="{ThemeResource TextControlThemeMinHeight}" />
                    <Setter Property="Foreground"
                            Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
                    <Setter Property="Background"
                            Value="{ThemeResource SystemControlBackgroundAltHighBrush}" />
                    <Setter Property="BorderBrush"
                            Value="{ThemeResource SystemControlForegroundChromeDisabledLowBrush}" />
                    <Setter Property="SelectionHighlightColor"
                            Value="{ThemeResource SystemControlHighlightAccentBrush}" />
                    <Setter Property="BorderThickness"
                            Value="{ThemeResource TextControlBorderThemeThickness}" />
                    <Setter Property="FontFamily"
                            Value="{ThemeResource ContentControlThemeFontFamily}" />
                    <Setter Property="FontSize"
                            Value="{ThemeResource ControlContentThemeFontSize}" />
                    <Setter Property="ScrollViewer.HorizontalScrollMode"
                            Value="Auto" />
                    <Setter Property="ScrollViewer.VerticalScrollMode"
                            Value="Auto" />
                    <Setter Property="ScrollViewer.HorizontalScrollBarVisibility"
                            Value="Hidden" />
                    <Setter Property="ScrollViewer.VerticalScrollBarVisibility"
                            Value="Hidden" />
                    <Setter Property="ScrollViewer.IsDeferredScrollingEnabled"
                            Value="False" />
                    <Setter Property="Padding"
                            Value="{ThemeResource TextControlThemePadding}" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="TextBox">
                                <Grid>
                                    <Grid.Resources>
                                        <Style x:Name="DeleteButtonStyle"
                                               TargetType="Button">
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="Button">
                                                        <Grid x:Name="ButtonLayoutGrid"
                                                              BorderBrush="{ThemeResource TextBoxButtonBorderThemeBrush}"
                                                              BorderThickness="{TemplateBinding BorderThickness}"
                                                              Background="{ThemeResource TextBoxButtonBackgroundThemeBrush}">
                                                            <VisualStateManager.VisualStateGroups>
                                                                <VisualStateGroup x:Name="CommonStates">
                                                                    <VisualState x:Name="Normal" />
                                                                    <VisualState x:Name="PointerOver">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
                                                                                                           Storyboard.TargetProperty="Foreground">
                                                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                                                        Value="{ThemeResource SystemControlHighlightAccentBrush}" />
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Pressed">
                                                                        <Storyboard>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ButtonLayoutGrid"
                                                                                                           Storyboard.TargetProperty="Background">
                                                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                                                        Value="{ThemeResource SystemControlHighlightAccentBrush}" />
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
                                                                                                           Storyboard.TargetProperty="Foreground">
                                                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                                                        Value="{ThemeResource SystemControlHighlightAltChromeWhiteBrush}" />
                                                                            </ObjectAnimationUsingKeyFrames>
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                    <VisualState x:Name="Disabled">
                                                                        <Storyboard>
                                                                            <DoubleAnimation Storyboard.TargetName="ButtonLayoutGrid"
                                                                                             Storyboard.TargetProperty="Opacity"
                                                                                             To="0"
                                                                                             Duration="0" />
                                                                        </Storyboard>
                                                                    </VisualState>
                                                                </VisualStateGroup>
                                                            </VisualStateManager.VisualStateGroups>
                                                            <TextBlock x:Name="GlyphElement"
                                                                       Foreground="{ThemeResource SystemControlForegroundChromeBlackMediumBrush}"
                                                                       VerticalAlignment="Center"
                                                                       HorizontalAlignment="Center"
                                                                       FontStyle="Normal"
                                                                       FontSize="12"
                                                                       Text="&#xE10A;"
                                                                       FontFamily="{ThemeResource SymbolThemeFontFamily}"
                                                                       AutomationProperties.AccessibilityView="Raw" />
                                                        </Grid>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </Grid.Resources>
                                    
                                    <!--VOTRE VISUAL STATE MANAGER-->
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="VisualStateGroup">
                                            <VisualState x:Name="On">
                                                <Storyboard>
                                                    <ColorAnimation Duration="0"
                                                                    To="#FF1F6E42"
                                                                    Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                                                    Storyboard.TargetName="QuitApp"
                                                                    d:IsOptimized="True" />
                                                </Storyboard>
                                            </VisualState>
                                            <VisualState x:Name="Off" />
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="Auto" />
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                    </Grid.RowDefinitions>
                                    <Border x:Name="BackgroundElement"
                                            Grid.Row="1"
                                            Background="{TemplateBinding Background}"
                                            Margin="{TemplateBinding BorderThickness}"
                                            Opacity="{ThemeResource TextControlBackgroundRestOpacity}"
                                            Grid.ColumnSpan="2"
                                            Grid.RowSpan="1" />
                                    <Border x:Name="BorderElement"
                                            Grid.Row="1"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="{TemplateBinding BorderThickness}"
                                            Grid.ColumnSpan="2"
                                            Grid.RowSpan="1" />
                                    <ContentPresenter x:Name="HeaderContentPresenter"
                                                      x:DeferLoadStrategy="Lazy"
                                                      Visibility="Collapsed"
                                                      Grid.Row="0"
                                                      Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}"
                                                      Margin="0,0,0,8"
                                                      Grid.ColumnSpan="2"
                                                      Content="{TemplateBinding Header}"
                                                      ContentTemplate="{TemplateBinding HeaderTemplate}"
                                                      FontWeight="Normal" />
                                    <ScrollViewer x:Name="ContentElement"
                                                  Grid.Row="1"
                                                  HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                                                  HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                                                  VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                                                  VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                                                  IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
                                                  IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
                                                  IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
                                                  Margin="{TemplateBinding BorderThickness}"
                                                  Padding="{TemplateBinding Padding}"
                                                  IsTabStop="False"
                                                  AutomationProperties.AccessibilityView="Raw"
                                                  ZoomMode="Disabled" />
                                    <ContentControl x:Name="PlaceholderTextContentPresenter"
                                                    Grid.Row="1"
                                                    Foreground="{ThemeResource SystemControlPageTextBaseMediumBrush}"
                                                    Margin="{TemplateBinding BorderThickness}"
                                                    Padding="{TemplateBinding Padding}"
                                                    IsTabStop="False"
                                                    Grid.ColumnSpan="2"
                                                    Content="{TemplateBinding PlaceholderText}"
                                                    IsHitTestVisible="False" />
                                    <Button x:Name="DeleteButton"
                                            Grid.Row="1"
                                            Style="{StaticResource DeleteButtonStyle}"
                                            BorderThickness="{TemplateBinding BorderThickness}"
                                            Margin="{ThemeResource HelperButtonThemePadding}"
                                            IsTabStop="False"
                                            Grid.Column="1"
                                            Visibility="Collapsed"
                                            FontSize="{TemplateBinding FontSize}"
                                            MinWidth="34"
                                            VerticalAlignment="Stretch" />
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>

    A noter que votre fichier App.xaml doit contenir vos ressources à cette emplacement : 

    <Application
        x:Class="MSDNSample.App"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:SpiderMSDN">
        <Application.Resources>
    
           <!--INSEREZ VOTRE STYLE ICI -->
    
        </Application.Resources>
    
    </Application>

    J'espère que j'ai bien répondu à votre question.

    Si c'est le cas, n'hésitez pas à mettre ma réponse en réponse à votre post

    Vous pouvez me suivre sur Twitter : https://twitter.com/NordineMhoumadi


    My blog : https://nordinemhoumadi.wordpress.com/

    vendredi 3 février 2017 13:07
  • Merci de votre réponse mais il ne s'agit pas de TextBox, mais de TextBloc et celui ci ne possède pas de propriété Template.


    JF Collombet ® CreateSpecificCulture


    vendredi 3 février 2017 14:59
  • J'ai finalement opter pour un Button plutôt qu'un TextBloc et j'en ai modifier le style de base pour obtenir

    les changements de couleur désirés selon l'action sur le Ajouter au dictionnaire également modifier  les paramètres pour ne plus afficher les Background et BorderBrush.

    Voici le code xaml si cela peut aider d'autres personnes.

    Merci à Nordine de m'avoir mis sur la voix.

    <Page
        x:Class="TestBtnStyle.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:TestBtnStyle"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
        <Page.Resources>
            <Style x:Key="ButtonStyle1" TargetType="Button">
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="Foreground" Value="{ThemeResource ButtonForeground}"/>
                <Setter Property="BorderBrush" Value="Transparent"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="Padding" Value="8,4,8,4"/>
                <Setter Property="HorizontalAlignment" Value="Left"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
                <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
                <Setter Property="FontWeight" Value="Normal"/>
                <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/>
                <Setter Property="UseSystemFocusVisuals" Value="True"/>
                <Setter Property="FocusVisualMargin" Value="-3"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Grid x:Name="RootGrid" Background="Transparent">
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal">
                                            <Storyboard>
                                                <PointerUpThemeAnimation Storyboard.TargetName="RootGrid"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="PointerOver">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" 
                                                                               Storyboard.TargetName="RootGrid">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <SolidColorBrush Color="Transparent"/>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" 
                                                                               Storyboard.TargetName="ContentPresenter">
                                                    <DiscreteObjectKeyFrame KeyTime="0" 
                                                                            Value="{ThemeResource ButtonBorderBrushPointerOver}"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" 
                                                                               Storyboard.TargetName="ContentPresenter">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <SolidColorBrush Color="Red"/>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                                <PointerUpThemeAnimation Storyboard.TargetName="RootGrid"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Pressed">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
                                                                               Storyboard.TargetName="RootGrid">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <SolidColorBrush Color="Transparent"/>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" 
                                                                               Storyboard.TargetName="ContentPresenter">
                                                    <DiscreteObjectKeyFrame KeyTime="0"
                                                                            Value="{ThemeResource ButtonBorderBrushPressed}"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" 
                                                                               Storyboard.TargetName="ContentPresenter">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <SolidColorBrush Color="Green"/>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                                <PointerDownThemeAnimation Storyboard.TargetName="RootGrid"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Disabled">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="RootGrid">
                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBackgroundDisabled}"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ContentPresenter">
                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBorderBrushDisabled}"/>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
                                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundDisabled}"/>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <ContentPresenter x:Name="ContentPresenter" AutomationProperties.AccessibilityView="Raw" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Page.Resources>
    
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <Button FontFamily="Segoe MDL2 Assets"
            Content="&#xE726;"
            FontSize="120" Style="{StaticResource ButtonStyle1}"/>
        </Grid>
    </Page>
    


    JF Collombet ® CreateSpecificCulture

    vendredi 3 février 2017 17:28