本文整理汇总了C#中System.Windows.HierarchicalDataTemplate.ItemContainerStyleSelector属性的典型用法代码示例。如果您正苦于以下问题:C# HierarchicalDataTemplate.ItemContainerStyleSelector属性的具体用法?C# HierarchicalDataTemplate.ItemContainerStyleSelector怎么用?C# HierarchicalDataTemplate.ItemContainerStyleSelector使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。
在下文中一共展示了HierarchicalDataTemplate.ItemContainerStyleSelector属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectStyle
public class TreeViewItemStyleSelector : StyleSelector
{
public override Style SelectStyle(object item, DependencyObject container)
{
string itemString = item as string;
string[] strings = itemString.Split(null);
int value;
if (!Int32.TryParse(strings[strings.Length - 1], out value))
{
return null;
}
StackPanel sp = ((Window1) Application.Current.MainWindow).sp1;
if (value < 5)
{
return sp.FindResource("TreeViewItemStyle1") as Style;
}
else
{
return sp.FindResource("TreeViewItemStyle2") as Style;
}
}
}
示例2: TreeViewData
public class TreeViewData : ObservableCollection<ItemsForTreeView>
{
public TreeViewData()
{
for (int i = 0; i < 100; ++i)
{
ItemsForTreeView item = new ItemsForTreeView();
item.TopLevelName = "item " + i.ToString();
Add(item);
}
}
}
public class ItemsForTreeView
{
public string TopLevelName { get; set; }
private ObservableCollection<string> level2Items;
public ObservableCollection<string> SecondLevelItems
{
get
{
level2Items ??= new ObservableCollection<string>();
return level2Items;
}
}
public ItemsForTreeView()
{
for (int i = 0; i < 10; ++i)
{
SecondLevelItems.Add("Second Level " + i.ToString());
}
}
}