0
當我通過DataContext設置treeviewitem的標題時,它添加了幾個可點擊的填充像素,然後使文本不可點擊。我將張貼一張圖片;藍色:可點擊,紅色:不可點擊。TreeViewItem無法使用datacontext進行選擇
存儲數據的類:
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; }
}
的XAML用於顯示數據:
<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>
您是在描述發生了什麼事情或您希望發生什麼?你想整個事情可點擊嗎? – 2012-08-01 13:36:38
並且可能放一些代碼? – 2012-08-01 13:46:57
更新了代碼,是的,我希望整個事情都是可點擊的。像一個普通的TreeViewItem – 2012-08-01 13:53:38