I have implemented a ToolBar and styling according to the following style. For the images I am using vector graphics from an .xaml resource file
<ResourceDictionaryxmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:Caliburn="http://www.caliburnproject.org"><Rectanglex:Key="ToolBarButtonIcon"x:Shared="False"Visibility="{Binding IconVisibility}"HorizontalAlignment="Stretch"VerticalAlignment="Stretch"Width="16"Height="16"><Rectangle.Fill><VisualBrushStretch="Uniform"Visual="{Binding IconSource}"/></Rectangle.Fill></Rectangle><Stylex:Key="ToolBarButton"TargetType="{x:Type Button}"BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"><Setter Property="Content" Value="{StaticResource ToolBarButtonIcon}"/><Setter Property="ToolTip" Value="{Binding ToolTipText}"/><Setter Property="ToolTipService.IsEnabled" Value="{Binding ToolTipServiceEnabled}"/><Setter Property="Caliburn:Action.Target" Value="{Binding}"/><Setter Property="Caliburn:Message.Attach" Value="{Binding ActionText}"/></Style></ResourceDictionary>
This renders the ToolBar great and all looks well, but when I dragged the ToolBar container the images became corrupted
![]()
To solve this I include the image binding in a control template so in the end the styles became
<Stylex:Key="ToolBarButton"TargetType="{x:Type Button}"BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"><Setter Property="ContentTemplate"><Setter.Value><DataTemplate><Rectangle x:Shared="False"
Visibility="{Binding IconVisibility}"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Width="16" Height="16"><Rectangle.Fill><VisualBrush Stretch="Uniform" Visual="{Binding IconSource}"/></Rectangle.Fill></Rectangle></DataTemplate></Setter.Value></Setter><Setter Property="ToolTip" Value="{Binding ToolTipText}"/><Setter Property="ToolTipService.IsEnabled" Value="{Binding ToolTipServiceEnabled}"/><Setter Property="Caliburn:Action.Target" Value="{Binding}"/><Setter Property="Caliburn:Message.Attach" Value="{Binding ActionText}"/></Style>
Now, the dragging works great
![]()
But now there is another problem. The tool tips for the button also become corrupt on the drag operations as do the Caliburn properties. Now, to get around this I have added the ToolTip and ToolTipService.IsEnabled properties to the rectangle, this indeed stops
the binding from failing, but it also means that the ToolTip does not show for mouse hover on the very edge of the buttons, the tool tips only show when the mouse is over the rectangle.
Now I have two questions:
1. How can I add tool tips to button itself so that the entire button surface will show the tool tip if the mouse hovers over it?
2. How can I handle the breaking of the bindings on the Caliburn properties?
Thanks for your time.
"Everything should be made as simple as possible, but not simpler" - Einstein