如何将样式表标记绑定到ViewModel属性

时间:2016-10-25 13:48:33

标签: css wpf mvvm viewmodel

假设我希望允许用户自定义应用程序界面(例如,更改字体系列或字体大小等)。 默认样式设置保存在样式表中,在Application.xaml文件中注册为ResourceDictionary。假设默认字体系列设置为Tahoma

    <FontFamily x:Key="FontFamilyDefault">Tahoma</FontFamily>
    ...
    <Style TargetType="{x:Type TextBox}">
    <Setter Property="FontFamily" Value="{DynamicResource FontFamilyDefault}"/>
    ...
    </Style>

现在假设用户可以通过ViewModel属性(FontFamily)设置字体系列。如何强制将动态资源FontFamilyDefault设置为FontFamily属性值? 感谢

0 个答案:

没有答案
相关问题