本文整理汇总了C#中System.Windows.Controls.Separator.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# Separator.SetBinding方法的具体用法?C# Separator.SetBinding怎么用?C# Separator.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Separator
的用法示例。
在下文中一共展示了Separator.SetBinding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFrameworkFoldersToContextMenu
private static void AddFrameworkFoldersToContextMenu(ContextMenu menu)
{
var visibilityBinding = new Binding("Path")
{
Converter = new StringToVisibilityConverter(),
ConverterParameter = "lib;content;tools;build"
};
var commandBinding = new Binding("AddContentFolderCommand");
bool addSeparator = menu.Items.Count > 0;
if (addSeparator)
{
var separator = new Separator();
separator.SetBinding(VisibilityProperty, visibilityBinding);
menu.Items.Insert(0, separator);
}
foreach (var pair in _frameworkFolders)
{
var item = new MenuItem
{
Header = String.Format(CultureInfo.CurrentCulture, "Add {0} folder", pair.Key),
Visibility = Visibility.Collapsed
};
item.SetBinding(VisibilityProperty, visibilityBinding);
string[] values = pair.Value;
if (values.Length > 2)
{
for (int i = 0; i < values.Length; i += 2)
{
var childItem = new MenuItem
{
Header = values[i],
CommandParameter = values[i + 1]
};
childItem.SetBinding(MenuItem.CommandProperty, commandBinding);
item.Items.Add(childItem);
}
}
else if (values.Length == 2)
{
item.SetBinding(MenuItem.CommandProperty, commandBinding);
item.CommandParameter = values[1];
}
else
{
// HACK: portable library menu item
item.SetBinding(MenuItem.CommandProperty, commandBinding);
item.CommandParameter = "portable";
}
menu.Items.Insert(0, item);
}
}