WPFUI控件库 |
您所在的位置:网站首页 › ps标题栏怎么改 › WPFUI控件库 |
1、功能说明 将窗体的标题栏改成自定义标题栏。 2、自定义控件库UiLib (1)、BaseWindow.cs namespace UiLib { public class BaseWindow:Window { public BaseWindow() { DefaultStyleKey = typeof(BaseWindow); CommandBindings.Add(new CommandBinding(SystemCommands.CloseWindowCommand, CloseWindow)); CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, ResizeWindow)); CommandBindings.Add(new CommandBinding(SystemCommands.MinimizeWindowCommand, MinimizeWindow)); } private void MinimizeWindow(object sender, ExecutedRoutedEventArgs e) { SystemCommands.MinimizeWindow(this); } private void ResizeWindow(object sender, ExecutedRoutedEventArgs e) { WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; } private void CloseWindow(object sender, ExecutedRoutedEventArgs e) { SystemCommands.CloseWindow(this); } protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); if (e.ButtonState == MouseButtonState.Pressed) DragMove(); } } }(2)、BaseWindow.xaml (3)、Generic.xaml 3、WPF应用程序 (1)、MainWindow.xaml (2)、MainWindow.cs namespace Demo { /// /// MainWindow.xaml 的交互逻辑 /// public partial class MainWindow : UiLib.BaseWindow { public MainWindow() { InitializeComponent(); } } } |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |