WPF制作Windows 10关闭按钮在自定义标题栏中
我需要为我的WPF应用程序构建一个自定义标题栏,仅使用“关闭”按钮,目前看起来像这样:
这是代码:
<Grid Width="32" Height="25" Margin="1" HorizontalAlignment="Right" MouseLeftButtonUp="OnCloseWindow" Grid.Column="4">
<Rectangle Fill="#FFE81123" Height="25" VerticalAlignment="Bottom"/>
<TextBlock Text="╳" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="#DDFFFFFF" />
</Grid>
我想要的是默认Windows 10关闭按钮的复制品动画,当您停止徘徊时,按钮会逐渐变成悬停的红色和白色。
我该怎么做?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过
来添加
windowStyle =“ toolwindow”
在
其中仅显示关闭按钮
来实现它。如果您想要与普通窗口相同的样式,则需要创建关闭按钮的样式。
检查此链接以获取参考
You can achieve it by adding
WindowStyle="ToolWindow"
in
It will show the close button only.
If you want the same style as the normal window, You need to create the style of the close button.
Check this link for reference
https://www.codemag.com/article/1903031/Create-a-Title-Bar-for-User-Controls
这是我使用的...
样式:
XAML中的按钮:
背后的代码:
This is what I use...
Style:
Button in XAML:
Code behind: