本文整理汇总了C#中MahApps.Metro.Controls.Flyout.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# Flyout.SetBinding方法的具体用法?C# Flyout.SetBinding怎么用?C# Flyout.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MahApps.Metro.Controls.Flyout
的用法示例。
在下文中一共展示了Flyout.SetBinding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFlyout
public void AddFlyout(string name, Type viewType, Position position, UnloadBehavior unloadBehavior = UnloadBehavior.SaveAndCloseViewModel)
{
Argument.IsNotNullOrWhitespace(() => name);
Argument.IsNotNull(() => viewType);
Log.Info("Adding flyout '{0}' with view type '{1}'", name, viewType.FullName);
var content = (UIElement) _typeFactory.CreateInstance(viewType);
var flyout = new Flyout();
flyout.Theme = FlyoutTheme.Adapt;
flyout.Position = position;
var flyoutInfo = new FlyoutInfo(flyout, content);
flyout.SetBinding(Flyout.HeaderProperty, new Binding("ViewModel.Title") {Source = content});
((ICompositeCommand) _commandManager.GetCommand("Close")).RegisterAction(() => { flyout.IsOpen = false; });
flyout.IsOpenChanged += async (sender, e) =>
{
if (!flyout.IsOpen)
{
var vmContainer = flyout.Content as IViewModelContainer;
if (vmContainer != null)
{
var vm = vmContainer.ViewModel;
if (vm != null)
{
switch (unloadBehavior)
{
case UnloadBehavior.CloseViewModel:
await vm.CloseViewModelAsync(null);
break;
case UnloadBehavior.SaveAndCloseViewModel:
await vm.SaveAndCloseViewModelAsync();
break;
case UnloadBehavior.CancelAndCloseViewModel:
await vm.CancelAndCloseViewModelAsync();
break;
default:
throw new ArgumentOutOfRangeException("unloadBehavior");
}
}
}
flyout.Content = null;
flyout.DataContext = null;
}
};
_flyouts[name] = flyoutInfo;
}