Wannabe Coder
Wannabe Coder

Reputation: 697

XAML Button Hover Effect

I have a button that uses a template. In my template, I have everything working correctly. My button shows correctly, with all images and text. But I would like to have a hover effect on my button. I've tried a style and a style trigger mouse over and neither worked. Can someone tell me how to get a hover effect on my button template below?

<Button Command="{Binding AppToolbarViewModel.RunToolAction, Source={StaticResource ViewModelLocator}}" CommandParameter="{Binding XamlURI}" ToolTip="{Binding ToolToolTip}"
Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Cursor="Hand">
    <Button.Template>
    <ControlTemplate>
        <StackPanel Orientation="Horizontal">
             <Grid>
                 <Label Content="&#xf0c8;" Style="{StaticResource FontAwesomeLabel}" />
                 <Label Content="{Binding ImageURI}" Style="{StaticResource FontAwesomeLabel}" FontSize="20" Margin="10,10,0,0" Foreground="GhostWhite" />
             </Grid>
             <Label Content="{Binding ToolName}" Style="{StaticResource ButtonLabel}" />
        </StackPanel>
    </ControlTemplate>
    </Button.Template>
</Button>

Upvotes: 0

Views: 468

Answers (1)

Daniel Jacobson
Daniel Jacobson

Reputation: 186

Sorry I can't comment (Don't have 50 reputation yet), but could you clarify what you mean by hover effect? Do you want a tooltip or do you want the style to change?

Regardless, if you want a tooltip you can refer to http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868199.aspx You can also add images as a tooltip if that is what you are trying to do.

If you want the style to change when you hover over, you can implement the "PointerEntered" and "PointerExited" event handler's and modify the style in the code-behind or using some other command.

Upvotes: 0

Related Questions