What is the best way to create toolbar buttons with separate active / disabled images in WPF?

I am working on a toolbar for a WPF application. The icon set that we use has separate icons for normal, hovering, and malfunctioning states, and I would like to use them. I was wondering what is the easiest solution / normal way to do this?

My first thought was to create a custom ImageButton control with the NormalImage, ActiveImage, DisabledImage properties that contained the necessary triggers for IsMouseOver and IsEnabled. This works, but, unfortunately, leads to the fact that the buttons lose the style of the button on the toolbar, i.e. Get the standard borders of the buttons, do not have a blue background when you hover over the mouse and are too close to each other. As far as I understand, this is due to the fact that the WPF toolbar toolbar overrides the style for the Button children and does not restore my buttons, because they are inside the parent ImageButton.

Does anyone have any job offers? I am new to WPF, so maybe I just approach this the other way around.

+4
source share
1 answer

You can create the style of your Button on the Style obtained by ToolBar.ButtonStyleKey . For instance:

 <Style TargetType="Button" BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"> <Setter Property="MinHeight" Value="40"/> </Style> 
+3
source

All Articles