本文整理匯總了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());
}
}
}