在WPF中通过鼠标悬停将按钮的样式更改为不同的样式
我刚刚开始使用 WPF,正在尝试设计一个应用程序来为我的志愿服务小组记录时间。无论如何,我试图让我的按钮看起来像 Windows 7 按钮的计算器,因为该应用程序也是用 WPF 设计的,而且它也会给整个团队留下深刻的印象。
我已经让它们看起来像计算器中的按钮(我的样式看起来像功能和数字按钮),但我无法让它们以相同的方式运行(正常的图片、鼠标悬停和单击附在最后)。我的 .xaml 结构如下,我在 app.xaml 中定义了 baseStyleButton
和 baseStyleButtonMouseOver
(我也需要定义此样式的帮助),然后我想设计“封装”两种基本样式的“styleButtonUniversal”,并在发生“MouseOver”事件时在它们之间切换。同样,我希望能够扩展此样式以具有 click
事件样式。
我如何在 WPF 中实现此目的,或者是否有其他方法可以设计我的按钮,使它们看起来很酷并且对于 WPF 初学者来说很容易?
另外,如果有人对如何实现计算器按钮的 MouseOver 外观有任何提示,我们也将不胜感激。
I have just started using WPF and I am trying to design an application for logging hours for my volunteering group. Anyhow I am trying to make my buttons look like the calculator for Windows 7 buttons since that application is also designed in WPF and it would also impress the whole group.
I have gotten them to look like the buttons from Calculator (I have styles that look like the function and the digit buttons) but I can't get them to behave in the same way (a picture of the normal, the MouseOver and the click are attached at the end). I have my .xaml structured in the following way, I have baseStyleButton
and baseStyleButtonMouseOver
(I need help with defining this style too) defined in app.xaml and then I want to design styleButtonUniversal
that "encapsulates" the two base styles and switches between them when the MouseOver
event occurs. Similarly, I want to be able to extend this style to have a click
event style too.
How do I achieve this in WPF or is there some other way that I can design my buttons that they both look cool and they are easy for a WPF beginner?
Also if anyone has any tips on how to achieve the MouseOver look of the calculator button, that would also be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您已经使用了控件模板?
您可以按如下方式应用样式触发器
I'm assuming your already using a control template?
You can apply style triggers as follows