I have created a custom Button component in my WinUI3 application. The code for the same is given below.
<Button
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
BorderThickness="0"
Width="{x:Bind Width}"
Height="{x:Bind Height}">
<StackPanel
Orientation="Vertical"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<FontIcon
VerticalAlignment="Center"
FontFamily="{StaticResource SymbolThemeFontFamily}"
Glyph="{x:Bind Glyph}"
FontSize="{x:Bind IconSize}" />
<TextBlock
VerticalAlignment="Center"
HorizontalAlignment="Center"
Margin="0,10,0,0"
Text="{x:Bind Label}"
FontSize="{x:Bind FontSize}" />
</StackPanel>
</Button>
By default, it is giving a very light grey colour background which is hardly visible in the white background of the page. So I want to change the background colour of the button when the cursor hovers over it, or when the button is in focus via tabs. Current Button on hover
How can I achieve this?
I tried <ControlTemplate>
, <VisualStateManager.VisualStateGroups>
<VisualState x:Name="PointerOver">
and <Storybaord>
but am unable to make it work.
I would want it to have a colour of my choice, so that it is more prominent. Just like it is in the default <AppBarButton>
Default WinUI3 AppBarButton on hover