#1,163 – Make an Image Clickable with a Control Template
September 22, 2014 1 Comment
You can allow clicking on an Image by using it as the control template for a Button.
In the example below, we define a button that consists of an image and a border that lights up when you hover over the image.
<StackPanel> <Button Click="Button_Click" Margin="10" HorizontalAlignment="Center" ToolTip="Click on Fred"> <Button.Template> <ControlTemplate> <Border x:Name="theBorder" BorderBrush="Transparent" BorderThickness="2"> <Image Source="Astaire.png" Height="45"/> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="BorderBrush" TargetName="theBorder" Value="LightSkyBlue"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Button.Template> </Button> </StackPanel>
Pingback: Dew Drop – September 22, 2014 (#1860) | Morning Dew