I have a templated treeview that is working just as i want, but i have a context menu which allows for a tier 1 node to be marked as "default".
I have a datatrigger which reacts to a property in the viewmodel, which should change the fontweight to bold just to visually show that this is the default node. But the setter will not change the fontweight on the button no matter what!
However if i change another value, like the foreground color for example, it works just fine, font size also no problem.
Why is this, can anyone explain this? Here is some code if needed:
Trigger:
<HierarchicalDataTemplate ItemsSource="{Binding Children,Mode=TwoWay,NotifyOnSourceUpdated=True}"> <StackPanel Orientation="Horizontal" VerticalAlignment="Top"> <Image x:Name="nodeImg" Source="{Binding Image}" MaxHeight="16" MaxWidth="16"/> <Button x:Name="nodeButton" Content="{Binding Name}" Command="{Binding Command}" Style="{StaticResource TreeMenuButton}"/> </StackPanel> <HierarchicalDataTemplate.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=TreeViewItem},Path=IsExpanded}" Value="True"> <Setter TargetName="nodeImg" Property="Source" Value="{Binding ImageExpanded}"></Setter> </DataTrigger> <DataTrigger Binding="{Binding IsDefaultConnection}" Value="True"> <Setter TargetName="nodeButton" Property="FontWeight" Value="Bold"></Setter> </DataTrigger> </HierarchicalDataTemplate.Triggers> </HierarchicalDataTemplate> Default style on button:
<Style x:Key="TreeMenuButton" TargetType="{x:Type Button}"> <Setter Property="SnapsToDevicePixels" Value="true" /> <Setter Property="OverridesDefaultStyle" Value="true" /> <Setter Property="MinHeight" Value="23" /> <Setter Property="MinWidth" Value="75" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Border x:Name="Border" CornerRadius="0" BorderThickness="0" Background="Transparent" BorderBrush="Transparent"> <ContentPresenter Margin="2" HorizontalAlignment="Left" VerticalAlignment="Center" RecognizesAccessKey="True"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style>
boldstyle, and if so, is it visually different at the size you are currently displaying?