本文整理汇总了C#中BarButtonItem.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# BarButtonItem.SetBinding方法的具体用法?C# BarButtonItem.SetBinding怎么用?C# BarButtonItem.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BarButtonItem
的用法示例。
在下文中一共展示了BarButtonItem.SetBinding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnModulesChanged
private void OnModulesChanged(IEnumerable<IVisualServiceMetadata> modules)
{
var moduleSorterService = VisualMainWindow.ApplicationProxy.ServicePool.GetSingelService<IModuleSorterService>();
var arrModules =
moduleSorterService.Sort(modules.Select(moduleSorterService.GenerateDescriptor)
.Except(new List<ModuleLayoutDescriptor> { null }));
var barManager = Parent as RibbonControl;
if (null == barManager) return;
Pages.Clear();
foreach (ModuleLayoutDescriptor mod in arrModules)
{
mod.OnVisibilityChangedDelegate = OnVisibilityChanged;
RibbonPage page = Pages.FirstOrDefault(p => p.Caption.ToString() == mod.Page /*Page.Name*/);
if (null == page)
{
page = new RibbonPage { Caption = mod.Page };
Pages.Add(page);
}
RibbonPageGroup group = page.Groups.FirstOrDefault(g => g.Caption == mod.Group);
if (null == group)
{
group = new RibbonPageGroup { Caption = mod.Group };
page.Groups.Add(group);
}
string name = mod.Label.Replace(" ", "_");
var bbi = new BarButtonItem();
bbi.SetBinding(BarItem.CommandProperty, new Binding("BarButtonItemCommand"));
bbi.SetValue(BarItem.CommandParameterProperty, mod);
bbi.Name = name;
bbi.Tag = mod;
bbi.IsEnabled = true; // mod.Enabled;
bbi.IsVisible = mod.Visible;
if (mod.LargeGlyph != null)
{
bbi.RibbonStyle = RibbonItemStyles.Large;
bbi.LargeGlyph = mod.LargeGlyph;
}
bbi.Content = mod.Label;
group.ItemLinks.Add(bbi);
}
UpdateVisibility();
}