How do you make one line bold in a TreeView Class in WPF/C#?

Topics: Prism v2 - WPF 4
Jun 1, 2010 at 5:33 AM

How do you make one line bold in a TreeView Class in WPF/C#?

I mean, how do you make just one line in a Tree View bold at runtime?

Developer
Jun 14, 2010 at 4:49 PM

Hi,

In order to make only one line bold at runtime in WPF you have to give the object containing that line a name, and then edit it in the code behind.

If you want to make a line inside a TreeViewItem bold, you could do something like this in the XAML:

<TreeView>
    <TreeViewItem Header="Item 1" >
        <TextBlock Name="BoldText">Bold Text</TextBlock>
        <TextBlock>Normal text</TextBlock>
    </TreeViewItem>
    <TreeViewItem Header="Item 2" >
        <TextBlock>Text</TextBlock>
    </TreeViewItem>
</TreeView>

and then something like this in the code behind:

BoldText.FontWeight = FontWeights.Bold;

As this is not related to Prism, you might get better support in the WPF forum.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi