当前位置:网站首页>Simple implementation of cool GUI window based on WPF
Simple implementation of cool GUI window based on WPF
2022-06-28 03:39:00 【Bright in snow】
「 Blog move 」 New address : Simple books
This paper aims to realize the implementation based on WPF Cool GUI window , Trying to achieve a really usable and practical GUI window .
The effect to be achieved in this paper is shown in the figure :
The results are summarized as follows :
- No title bar , Or customize the title bar
- The translucency of the window
- Windows are free to drag and drop
- Enter as well as Esc Wait for the default key
- Right-click menu
1. The effect of the window is realized
1.1 Window appearance related
First, create a new window , Change the look , Set the properties of the window as follows :
Appearance settings , 「AllowsTransparency」 Check the check box , The window can be made transparent , meanwhile 「WindowStyle」 Will automatically change to 「None」, The default title bar of the window disappears , You can choose to customize the title bar .
After the window allows transparency , stay 「Background」、「BorderBrush」 And so on , Set the background and border color of the form . It can be set to solid color, various gradient shapes and various transparent shapes .
Use 「BorderThickness」 Item to set the border width of the form .
「Opacity」 Set the opacity of the entire interface
The setting interface is shown in the following figure :
1.2 Window size position dependent
Change the position of the window , Set the following properties :
- WindowStartupLocation: Change the position when the window is opened
- WindowState: Change the size of the window when it is opened , Full screen window can be set
- Topmost: Top this window
- Width and Height: The size of the window when it is opened
- MinWidth and MinHeight: The minimum size of the window
2. It is convenient to realize the function of window operation
For the convenience of window operation , The following settings can be made :
Set up a button Properties of , Set up IsCancel and IsDefault attribute , Can be set up Enter and Esc Button triggered by key .
Set the window to be dragged anywhere , The event calling method of the window can be set , Set up MouseLeftButtonDown The calling method of the event .
The setting method is as follows :
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DragMove();
}
Click the close button to end the entire application , You can set the callback method for closing events , You can also set the method of button click event , as follows :
private void btnExit_Click(object sender, RoutedEventArgs e)
{
Environment.Exit(0);
}
Realize the right-click menu of the window and its click event , You need to set the window 「ContextMenu」 attribute , Or in the Xaml In file , Add the following :
<Window.ContextMenu>
<ContextMenu Name="ChangePassword">
<MenuItem Header=" Change login password " Click="MenuItemChangePassword_Click" />
<MenuItem Header=" About " Click="MenuItemAbout_Click" />
</ContextMenu>
</Window.ContextMenu>
边栏推荐
- 2022安全员-C证考试题库模拟考试平台操作
- nn.Parameter和torch.nn.init系列函数给模型参数初始化
- Basic operation of stack (implemented in C language)
- Etcd database source code analysis -- network layer server rafthandler between clusters
- What are the technologies to be mastered in the test? Database design for software testing
- SSH框架的搭建(下)
- 数据库系列之MySQL配置F5负载均衡
- Hot! Yolov6's fast and accurate target detection framework is open source (with source code download)
- matlab习题 —— 符号运算相关练习
- Use js programming questions [split] in Niuke
猜你喜欢
WPF 下的自定义控件以及 Grid 中控件的自适应
mysql获取当前时间是一年的第多少天
PPT制作小技巧
How to write concise code? (upper)
How does the open-ended Hall current sensor help the transformation of DC power distribution?
Tardigrade:Trino 解决 ETL 场景的方案
ETCD数据库源码分析——集群间网络层服务端RaftHandler
__ getitem__ And__ setitem__
资源管理、高可用与自动化(下)
collections. Use of defaultdict()
随机推荐
WARN:&nbsp;SQL&nbsp;Error:&nbsp;…
Ten years' experience of Software Engineer
"9 No" principle and "5 measurement dimensions" of extensible system
Documentation issues
INFO:&nbsp;HHH000397:&nbsp;Using…
新手开哪家的证券账户是比较好?炒股开户安全吗
Is your IOT security strong enough?
《Go题库·12》slice和array区别?
matlab习题 —— 矩阵的常规运算
数据库系列之MySQL和TiDB中慢日志分析
MySQL错误
Lost connection repair: make "hide and seek" nowhere to hide
失联修复:让“躲猫猫”无处可藏
17 `bs对象.节点名h3.parent` parents 获取父节点 祖先节点
Go 数据类型篇(四)之浮点型与复数类型
【小程序】使用font-awesome字体图标的解决文案(图文)
Necessary software tools in embedded software development
数据库乱码问题
力扣每日一题-第29天-219.存在重复元素Ⅱ
Change of monitoring documents and folders of "operation and maintenance department"