0

When I set the treeviewitem's header via a DataContext, it adds a few pixels of padding that are clickable, and then puts the text with isn't clickable. I shall post an image; blue: clickable, red: unclickable.

The classes that store the data:

public class TagClass
{
    public string TagClassMagic { get; set; }
    public ITagClass RawClass { get; set; }
    public List<TagEntry> TagEntries = new List<TagEntry>();

    public IList Children
    {
        get
        {
            return new CompositeCollection()
                {
                    new CollectionContainer() { Collection = TagEntries }
                };
        }
    }

}
public class TagEntry
{
    public string TagFileName { get; set; }
    public ITagEntry RawTag { get; set; }
}

The XAML for displaying the Data:

<TreeView x:Name="tvTagList" Margin="15, 40, 15, 50" ItemsSource="{Binding}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="{x:Null}" BorderBrush="{DynamicResource ExtryzeAccentBrushSecondary}" BorderThickness="2" ScrollViewer.CanContentScroll="True" Foreground="White">
    <TreeView.Resources>
        <HierarchicalDataTemplate DataType="{x:Type  DataBind:TagClass}" ItemsSource="{Binding Children}" >
            <TreeViewItem Header="{Binding TagClassMagic}" />
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate DataType="{x:Type DataBind:TagEntry}"  >
            <TreeViewItem Header="{Binding TagFileName}" />
        </HierarchicalDataTemplate>
    </TreeView.Resources>
</TreeView>
Alexander Forbes-Reed
  • 2,823
  • 4
  • 27
  • 44

1 Answers1

2

Try to remove this ones:

<TreeViewItem Header="{Binding TagClassMagic}" />
<TreeViewItem Header="{Binding TagFileName}" />

and instead add a data templates for TagEntry accordingly - put just simple textblocks in those data templates

niao
  • 4,972
  • 19
  • 66
  • 114