谢谢!
解决方法 这是怎么做的.您使用ContentControl并将ControlTemplate指定为静态资源: –<GrID.Resources> <ControlTemplate x:Key="CommonTextBlock" targettype="ContentControl"> <TextBlock Opacity="{Binding SomeOpacity}" Text="{TemplateBinding Content}" /> </ControlTemplate><GrID.Resource><ContentControl Content="{Binding SomeTextValue}" Template="{StaticResource CommonTextBlock}" /><ContentControl Content="{Binding SomeOtherTextValue}" Template="{StaticResource CommonTextBlock}" />
现在,您可以随意绑定绑定到控件模板的其他属性.
这种方法可以扩展到样式:
<GrID.Resources> <ControlTemplate x:Key="CommonTextBlock" targettype="ContentControl"> <TextBlock Opacity="{Binding SomeOpacity}" Text="{TemplateBinding Content}" /> </ControlTemplate> <Style x:Key="CommonTextBlockStyle" targettype="ContentControl"> <Setter Property="Template" Value="{StaticResource CommonTextBlock}" /> <Setter Property="Foreground" Value="Blue" /> </Style><GrID.Resource><ContentControl Content="{Binding SomeTextValue}" Style="{StaticResource CommonTextBlockStyle}" /><ContentControl Content="{Binding SomeOtherTextValue}" Style="{StaticResource CommonTextBlockStyle}" />总结
以上是内存溢出为你收集整理的Silverlight:如何在setter中使用一个绑定的样式(或等效的工作)全部内容,希望文章能够帮你解决Silverlight:如何在setter中使用一个绑定的样式(或等效的工作)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)