Пример #1
0
        private void close_btn_Click(object sender, RoutedEventArgs e)
        {
            Window win     = (Window)((FrameworkElement)sender).TemplatedParent;
            var    setting = WindowTheme.GetTheme(win);

            if (setting == null || setting.ExitCommand == null)
            {
                win.Close();
            }
        }
Пример #2
0
        private void min_btn_Click(object sender, RoutedEventArgs e)
        {
            Window win = (Window)((FrameworkElement)sender).TemplatedParent;

            var setting = WindowTheme.GetTheme(win);

            if (setting == null || setting.MinButton == Visibility.Visible)
            {
                win.WindowState = WindowState.Minimized; //设置窗口最小化
                e.Handled       = true;
            }
        }
Пример #3
0
        private void max_btn_Click(object sender, RoutedEventArgs e)
        {
            Window win     = (Window)((FrameworkElement)sender).TemplatedParent;
            var    setting = WindowTheme.GetTheme(win);

            if (setting == null || setting.MaxButton == Visibility.Visible)
            {
                if (win.WindowState == System.Windows.WindowState.Maximized)
                {
                    win.WindowState = System.Windows.WindowState.Normal;
                    return;
                }
                win.WindowState = System.Windows.WindowState.Maximized;
                e.Handled       = true;
            }
        }
Пример #4
0
 /// <summary>
 /// 设置一个对象的主题属性
 /// </summary>
 /// <param name="dpo"></param>
 /// <param name="value"></param>
 public static void SetTheme(DependencyObject dpo, WindowTheme value)
 {
     dpo.SetValue(ThemeProperty, value);
 }