I am trying to use the xaml below to define a Button that will:
- have an image
- have concatenated text, partly from an external resx & partly from a vm property
- have an accelerator key based on the first letter of the text
The markup below gives me the image and text, but doesn’t work as an accelerator key (the “_” doesn’t hide and Alt-A doesn’t work).
How can I fix the markup to get accelerator key functionality?
Current markup and behavior
<Style x:Key="AddNewItemButtonStyle" BasedOn="{StaticResource blueButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="Content">
<Setter.Value>
<StackPanel Orientation="Horizontal" >
<Image Source="{resx:Resx ResxName=Presentation.Resources.MasterDetail, Key=bullet_add}" Stretch="Uniform" />
<TextBlock Text="_"/>
<TextBlock Text="{resx:Resx ResxName=Presentation.Resources.MasterDetail, Key=Subject_AddNew}" />
<TextBlock Text=" "/>
<TextBlock Text="{Binding Subject}" />
</StackPanel>
</Setter.Value>
</Setter>
<Setter Property="Command" Value="{Binding AddNewItemCommand}" />
</Style>

Update w/ HB’s code
Nothing BUT the image:

<Style x:Key="AddNewItemButtonStyle" BasedOn="{StaticResource blueButtonStyle}" TargetType="{x:Type Button}">
<Setter Property="Content" >
<Setter.Value>
<MultiBinding StringFormat="_{0} {1} {2}">
<Binding Source="{resx:Resx ResxName=Presentation.Resources.MasterDetail, Key=Add}"/>
<Binding Source="{resx:Resx ResxName=Presentation.Resources.MasterDetail, Key=New}"/>
<Binding Path="Subject"/>
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<StackPanel Orientation="Horizontal">
<Image Source="{resx:Resx ResxName=Presentation.Resources.MasterDetail, Key=bullet_add}" Stretch="Uniform" />
<ContentPresenter/>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Command" Value="{Binding AddNewItemCommand}" />
</Style>
You can use AccessText with a multi-binding