更改WPF按钮的形状而不改变其他风格 [英] Change shape of WPF button without changing other styles

查看:683
本文介绍了更改WPF按钮的形状而不改变其他风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从默认的圆角矩形一个WPF按钮的形状改变为另一种形状(例如,箭头),但我想保持造型的其余部分 - 填充颜色,边框颜色,悬停状态,等我希望按钮具有相同的样式,所有其他常规按钮(我相信是根据Windows的版本,系统主题颜色等,所以它不喜欢我可以从头开始重新创建和硬$ c中的按钮样式c中的正确的颜色$)。

I would like to change the shape of a WPF button from the default round rectangle to another shape (say, an arrow), but I want to keep the rest of the styling -- fill color, border color, hover states, etc. I want the button to have the same styles as all the other regular buttons (which I believe depends on the version of Windows, system theme colors, etc. so it's not like I can recreate the button style from scratch and hard code the right colors).

有没有一些方法来做到这一点?

Is there some way to do that?

推荐答案

您应该能够继承正常的按钮控制。然后,您可以自定义子类的按钮,自定义形状,但所有其他属性将被继承。这将允许您更改形状的按钮而已。

You should be able to subclass the normal button control. You can then customize the subclassed button with a custom shape, but all other properties would be inherited. This would allow you to change the shape for your button and nothing else.

下面是创建一个自定义的按钮,如果你有混合一个很好的资源:
http://msdn.microsoft.com/en-us/library/bb613598.aspx

Here's a good resource for creating a custom button if you have Blend:
http://msdn.microsoft.com/en-us/library/bb613598.aspx

这篇关于更改WPF按钮的形状而不改变其他风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆