将字体设置为Silverlight中的应用程序 [英] set font to application in silverlight
本文介绍了将字体设置为Silverlight中的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想允许用户从下拉列表中选择字体,并且整个应用程序中的所有文本框和标签都使用相同的样式...如何隐含这一点?
I want to allow user to select fonts from dropdown and same shold apply to all Textbox and Labels in whole application...how to impliment this?
推荐答案
您需要指定一些在应用程序中使用的资源文件.您的绑定应该是DynamicResource而不是StaticResource.
FontFamily ="{DynamicResource CoolFont}"
因此,您的下拉菜单中应包含一个事件,该事件在选中某项时会触发.然后,此事件应执行以下操作:
you need to specify some resource files that is then used in the application. Your bindings should be DynamicResource not StaticResource.
FontFamily="{DynamicResource CoolFont}"
so, your dropdown should have an event that is fired when an item is selected. This event should then do something like:
Application.Current.Resources = Application.LoadComponent(New Uri(resourceDictionaryName, UriKind.Relative))
resourceDictionaryName是资源文件(例如NewFont.xaml).
这一切都与应用程序外观有关!!!
The resourceDictionaryName being the resource file (say NewFont.xaml).
This is all about application skinning!!!
这篇关于将字体设置为Silverlight中的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文