コード例 #1
0
        private static MetroWindow GetMetroWindow(object context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (!DialogParticipation.IsRegistered(context))
            {
                throw new InvalidOperationException("Context is not registered. Consider using DialogParticipation.Register in XAML to bind in the DataContext.");
            }
            MetroWindow window = Window.GetWindow(DialogParticipation.GetAssociation(context)) as MetroWindow;

            if (window == null)
            {
                throw new InvalidOperationException("Control is not inside a MetroWindow.");
            }
            return(window);
        }
コード例 #2
0
ファイル: DialogCoordinator.cs プロジェクト: Lv000001/MetroUI
        private static MetroWindow GetMetroWindow(object context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (!DialogParticipation.IsRegistered(context))
            {
                throw new InvalidOperationException("Context is not registered. Consider using DialogParticipation.Register in XAML to bind in the DataContext.");
            }

            var association = DialogParticipation.GetAssociation(context);
            var metroWindow = association.Invoke(() => Window.GetWindow(association) as MetroWindow);

            if (metroWindow == null)
            {
                throw new InvalidOperationException("Context is not inside a MetroWindow.");
            }
            return(metroWindow);
        }