当前位置:网站首页>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>边栏推荐
- Websocket (simple experience version)
- Is Guotai Junan Securities reliable? Is it safe to open a securities account?
- 资源管理、高可用与自动化(下)
- Import an excel file, solve the problem of skipping blank cells without reading and moving the subscript forward, and return_ BLANK_ AS_ Null red
- Summary of the use of composition API in the project
- 云应用、服务的“5层”架构
- Resource management, high availability and automation (Part 2)
- 自用工具 猴子都会用的unity视频播放器
- 第二轮红队免费公开课来袭~明晚八点!
- Sublime Text 3 基本配置教程
猜你喜欢

文件的相对路径写法
![Redis cluster setup [simple]](/img/20/9974a290f8c5d346e2b404b48b02e5.png)
Redis cluster setup [simple]

Tencent games released more than 40 products and projects, including 12 new games

爱普生L3153打印机如何清洗喷头

matlab习题 —— 符号运算相关练习

Self use tool unity video player that monkeys can use

Websocket (simple experience version)

Solution to not displaying logcat logs during debugging of glory V8 real machine

Lost connection repair: make "hide and seek" nowhere to hide

数据库系列之MySQL中的执行计划
随机推荐
Win 10出现bitlocke恢复,蓝屏错误代码0x1600007e
失联修复:让“躲猫猫”无处可藏
Establishment of SSH Framework (Part I)
数据库系列之MySQL中的分页查询优化
Relative path writing of files
Introduction to kubernetes resource object and common commands
在牛客中使用JS编程题【split】
R1 Quick Open Pressure Vessel Operation Special Operation Certificate Examination Library and Answers in 2022
Resource management, high availability and automation (Part 2)
Scalable storage system (I)
Websocket (simple experience version)
可扩展数据库(下)
ETCD数据库源码分析——集群间网络层服务端RaftHandler
matlab习题 —— 矩阵的常规运算
爱普生L3153打印机如何清洗喷头
数据库
「运维有小邓」监控文件及文件夹变更
电子地图坐标系统研究整理
基于 WPF 的酷炫 GUI 窗口的简易实现
"9 No" principle and "5 measurement dimensions" of extensible system