Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Custom Button using triggers and updateable image

$
0
0

So I have a custom button with an image and MouseOver trigger defined in XMAL.  It looks fine, but I would like to be able to change the image when I place my custom button on my window control.  Not sure how to enable this feature.

<UserControl x:Class="STXInvoices.ctlRoundedButtonWithImage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300"><Control.Resources><Style x:Key="RoundedButtonWithImage" TargetType="{x:Type Button}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type Button}"><Grid x:Name="grdRoundedButtonWithImage"><Border x:Name="border" CornerRadius="4" BorderBrush="#6A696B" BorderThickness="1"><Border.Background><LinearGradientBrush EndPoint="0.504,1.5" StartPoint="0.504,0.01"><GradientStop Color="#FFFFFFFF" Offset="-0.2"/><GradientStop Color="#C5C5C5" Offset="0.7"/></LinearGradientBrush></Border.Background><Image Height="16" Width="16" Stretch="Uniform" Name="imgRoundedButtonWithImage" Source="RES_UI\RightArrow.png"/></Border></Grid><ControlTemplate.Triggers><MultiTrigger><MultiTrigger.Conditions><Condition Property="IsMouseOver" Value="True" /></MultiTrigger.Conditions><MultiTrigger.Setters><Setter Property="Background" TargetName="border"  Value="#E0E0E0"></Setter></MultiTrigger.Setters></MultiTrigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style></Control.Resources><Grid><Button x:Name="button" Style="{StaticResource RoundedButtonWithImage}" Click="onButtonClick" /></Grid></UserControl>


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>