Dynamically changing image in C1ToolbarButton

Posted by: elogsdon on 16 April 2021, 7:30 am EST

    • Post Options:
    • Link

    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

    C1ToolbarButtonImage.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels