当前位置: 首页>>代码示例>>C#>>正文


C# ChildWindow.Focus方法代码示例

本文整理汇总了C#中System.Windows.Controls.ChildWindow.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# ChildWindow.Focus方法的具体用法?C# ChildWindow.Focus怎么用?C# ChildWindow.Focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.ChildWindow的用法示例。


在下文中一共展示了ChildWindow.Focus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PopupMessage

        public static ChildWindow PopupMessage(string title, string message, string closeButtonLabel, bool closeWindow)
        {
            if (CurrentPopup != null)
                return null;

            var msgBox = new ChildWindow();
            CurrentPopup = msgBox;
            
            msgBox.Style = Application.Current.Resources["PopupMessageWindow"] as Style;
            msgBox.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xBA, 0xD2, 0xEC));
            msgBox.Title = title;
            msgBox.MaxWidth = Application.Current.Host.Content.ActualWidth * 0.5;

            StackPanel content = new StackPanel();
            content.Children.Add(new TextBlock() { Text = message, Margin = new Thickness(20), Foreground = new SolidColorBrush(Colors.White), FontSize = 14, HorizontalAlignment=HorizontalAlignment.Center });

            Button closeButton = new Button { Content = closeButtonLabel, FontSize = 14, HorizontalAlignment = HorizontalAlignment.Center, Margin = new Thickness(20) };
            closeButton.Click += (s, o) =>
                                     {
                                         msgBox.Close();
                                         if (closeWindow)
                                         {
                                             BrowserWindow.Close();
                                         }
                                     };
            content.Children.Add(closeButton);
            msgBox.Content = content;
            msgBox.IsTabStop = true;
            
            msgBox.Show();
            msgBox.Focus();
            
            _currentWindow = msgBox;
            PopupManager.CloseActivePopup();
            return msgBox;
        }
开发者ID:nhannd,项目名称:Xian,代码行数:36,代码来源:PopupHelper.cs

示例2: PopupContent

        public static ChildWindow PopupContent(string title, object content, IEnumerable<Button> buttons)
        {
            if (CurrentPopup != null)
                return null;

            var msgBox = new ChildWindow();
            CurrentPopup = msgBox;
            msgBox.Style = Application.Current.Resources["PopupMessageWindow"] as Style;
            msgBox.BorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xBA, 0xD2, 0xEC));
            msgBox.Title = title;

            msgBox.MaxWidth = Application.Current.Host.Content.ActualWidth * 0.5;

            StackPanel panel = new StackPanel();
            panel.Children.Add(new ContentPresenter() { Content = content });

            StackPanel buttonPanel = new StackPanel() { Margin = new Thickness(20), Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center };

            if (buttons != null)
            {
                foreach (Button b in buttons)
                {
                    b.Click += (s, e) =>
                    {
                        msgBox.Close();
                    };
                    buttonPanel.Children.Add(b);
                }

            }
            else
            {
                var closeButton = new Button { Content = Labels.ButtonClose, HorizontalAlignment = HorizontalAlignment.Center, };
                closeButton.Click += (s, e) =>
                {
                    msgBox.Close();
                };
                buttonPanel.Children.Add(closeButton);

            }

            panel.Children.Add(buttonPanel);
            msgBox.Content = panel;

            msgBox.IsTabStop = true;
            msgBox.Show();
            msgBox.Focus();

            PopupManager.CloseActivePopup();
            return msgBox;
        }
开发者ID:nhannd,项目名称:Xian,代码行数:51,代码来源:PopupHelper.cs


注:本文中的System.Windows.Controls.ChildWindow.Focus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。