I need some help with XAML. It should be easy but unfortunately I can’t figure out.
I have border & defined buttons inside.
The problem is that when button is pressed it leaves focused (blue square around).
But it would be nice to make button unpressed (not focused) same as ToolBar control does.
Here will be a part of XAML:
<Border DockPanel.Dock="Top" Height="75" Style="{StaticResource GradientToolBarBorder}">
<StackPanel Orientation="Horizontal">
<c:ToolBarImageButton Image="Resources/connect.png" Text="Connect"/>
</StackPanel>
</Border>
ToolBar Image Button:
<Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Margin="5">
<StackPanel Orientation="Vertical">
<Image Source="{Binding ElementName=ToolBarImgButton, Path=Image}" Stretch="None" RenderOptions.BitmapScalingMode="NearestNeighbor" />
<TextBlock Text="{Binding ElementName=ToolBarImgButton, Path=Text}" Margin="0,2,0,0"/>
</StackPanel>
</Button>
Thanks.
Since there is no OOTB support for losing focus the simplest solution will be adding hidden control and setting focus to it everytime you need.
Read-only textbox would be the safest option here.
If eventhandlers are used for buttons then just call
hidden.Focus()method in it.However, in case of commanding (MVVM pattern) you will need to use Attached Properties as described here