Now I only want to change the button's background to #f5f5f5 when mouseover it.
WPF has a trigger function which can do it easily.
Whereas I heard that UWP has no trigger any more,but with other function instead,like this question:
Trigger element (XAML) is not supported in a UWP project
I did it with DataTriggerBehavior as the tutorial:
<ControlTemplate TargetType="Button" x:Key="ButtonControlTemplate">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" VerticalAlignment="{TemplateBinding VerticalAlignment}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" Name="ButtonBorder" Background="{TemplateBinding Background}">
<ContentPresenter FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Foreground="{TemplateBinding Foreground}"></ContentPresenter>
</Border>
<Interactivity:Interaction.Behaviors>
<Core:DataTriggerBehavior Binding="{Binding PointerMovedEvent, ElementName=ButtonBorder}" Value="true">
<Core:ChangePropertyAction TargetObject="{Binding ElementName=ButtonBorder}" PropertyName="Background" Value="#f5f5f5" />
</Core:DataTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</ControlTemplate>
The programme can works successfully,but can't change the background.
Oh,my god.
I have tried the VisualState also,but I can't find a tutorial so I don't know how to use it.
What's more,I can hardly know why microsoft do not use trigger any more.
Would you please help me how to solve my problem?
Thanks a lot!