更改WPF按钮的形状而不改变其他风格而不、形状、按钮、风格

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

我想从默认的圆角矩形一个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

阅读全文

相关推荐

最新文章