Hello
I have a ListBox using the next ItemTemplate:
<
DataTemplatex:Key="MenuItemTemplate"><
StackPanelMargin="0,5,0,0"Width="100"><
ImageWidth="48"Source="Images\gears.png"Height="48"/><
TextBlockBackground="{x:Null}"FontSize="12"FontWeight="Normal"Text="{Binding Mode=OneWay, XPath=Title}"TextWrapping="Wrap"d:LayoutOverrides="Width"HorizontalAlignment="Center"x:Name="tbText"/></
StackPanel></
DataTemplate>
Now I also run over the ItemContainerStyle to remove the blue rectangle when item selection occur, I also removed the default white Foreground, instead I added a blue border, until here no problems:
<
Stylex:Key="MenuItemsContainerStyle"TargetType="{x:Type ListBoxItem}"><
SetterProperty="Background"Value="Transparent"/><
SetterProperty="Template"><
Setter.Value><
ControlTemplateTargetType="{x:Type ListBoxItem}"><
BorderSnapsToDevicePixels="true"x:Name="Bd"Background="{TemplateBinding Background}"BorderBrush="{TemplateBinding BorderBrush}"BorderThickness="{TemplateBinding BorderThickness}"Padding="{TemplateBinding Padding}"><
ContentPresenterSnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/></
Border><
ControlTemplate.Triggers><
TriggerProperty="IsSelected"Value="true"><
SetterProperty="BorderBrush"TargetName="Bd"Value="{DynamicResource {xtatic SystemColors.HighlightBrushKey}}"/><
SetterProperty="BorderThickness"TargetName="Bd"Value="1" /></
Trigger><
TriggerProperty="IsEnabled"Value="false"><
SetterProperty="Foreground"Value="{DynamicResource {xtatic SystemColors.GrayTextBrushKey}}"/></
Trigger></
ControlTemplate.Triggers></
ControlTemplate></
Setter.Value></
Setter></
Style>
Now the thing is I want to set the TextBlock font weight Bold!!!
How can I achieve that, how can I chenge properties of a control inside my template when the ListBoxItem is selected?
The next line does not work so please do not give me that solution:
<SetterProperty="FontWeight"Value="Bold"/>
Thanx
Itzik
P.S
I also want to change the ImageSource but I assume it will be done the same