I am using two button in WPF i want to change their image ie image button on DIsable how to do it can any one help me?
2 Answers
You cann't change Image, since in WPF Button is just a button as @Daniel Hilgarth wrote. However you can make new style for button like - and apply it to your buttons. This might work like your requirements.
<Style x:Key="BtnStyle" TargetType="{x:Type Button}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<!--Image-->
<Image x:Name="BtnImage" Stretch="Fill" />
<ContentPresenter Margin="2" HorizontalAlignment="Center" RecognizesAccessKey="True" VerticalAlignment="Center" />
</Grid>
<ControlTemplate.Triggers>
<!--Trigger for IsEnabled-->
<Trigger Property="IsEnabled" Value="false">
<!--Set the source of the image-->
<Setter TargetName="BtnImage" Property="Source" Value="pack://application:,,,/YouAppShortName;component/Image.png" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>