不同的按钮状态使用不同的字体
我在 Silverlight 中使用切换按钮控件。请告诉我如何为其选中和未选中状态使用不同的字体系列。我尝试使用 Expression Blend 编辑切换按钮模板,但无法使其工作。请帮忙。
谢谢, 奥马尔·贾韦德
I am using a Toggle button control in Silverlight. Please tell how can i use a different font family for its Checked and Unchecked states. I have tried editing Toggle button template using Expression Blend but could not make it work. Please help.
Thanks,
Omer Javed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用转换器并将 Button 内 TextBlock 的 FontFamily 属性绑定到按钮的 IsChecked 状态。
C# 中的转换器大致如下所示:
虽然就我个人而言 - 我会继续尝试使该模板正常工作 - 可能与 VisualStateManager 处理到“已检查”状态的转换有关。
You can use a converter and bind the FontFamily property of the TextBlock inside the Button to the IsChecked state of the button.
And the converter in C# would look rouguhly like this:
Though personally - I would keep trying to get that template to work - probably something to do with the VisualStateManager handling the transition to "Checked" state.
最简单的方法是使用内置行为
ChangePropertyAction
。由于您已经提到您已安装了 Expression Blend,因此只需转到资源面板并输入“ChangePropertyAction”,然后将此行为拖放到ToggleButton
顶部即可。之后,您只需指定在哪个事件触发后您想要更改什么。有关如何使用此行为的更多信息,请参阅这篇文章。
一些示例代码
The easist way would be to use a built-in behaivor
ChangePropertyAction
. Since you have mentioned that you have Expression Blend installed, just go to the Asset Panel and type in 'ChangePropertyAction', then drag and drop this behavior on top of yourToggleButton
.After that you just need to specify after which event fires you want to change what. For more information regarding how to use this behavior, please see this post.
Some example code