Posted 16 April 2021, 7:30 am EST
Is there a sample on changing the image of a C1ToolbarButton based on the IsEnabled state?
Thanks,
Eric
Forums Home / ComponentOne / WPF Edition
Posted by: elogsdon on 16 April 2021, 7:30 am EST
Posted 16 April 2021, 7:30 am EST
Is there a sample on changing the image of a C1ToolbarButton based on the IsEnabled state?
Thanks,
Eric
Posted 18 April 2021, 6:59 pm EST
Hi Eric,
You can achieve this functionality by modifying the C1ToolbarButton’s Template as follows:
<StackPanel x:Name="LargeView">
<!--Disabled Large Image-->
<Image x:Name="img1_disabled" Source="{TemplateBinding DisabledLargeImageSource}" Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:C1ToolbarButtonEx}, Converter={StaticResource VisibilityConverter}, ConverterParameter=R}" Stretch="None"/>
<!--Enabled Large Image-->
<Image x:Name="img1" Source="{TemplateBinding LargeImageSource}" Stretch="None" Visibility="{Binding Path=IsEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:C1ToolbarButtonEx}, Converter={StaticResource VisibilityConverter}}"/>
<TextBlock x:Name="LargeText" Foreground="{TemplateBinding ActualForeground}" TextAlignment="Center" Text="{Binding LabelTitle}"/>
</StackPanel>
Similarly you can modify the SmallImageSource as well. Please refer to the attached sample for the same. (see C1ToolbarButtonImage.zip)
Best Regards,
Kartik