开发者

Apply styles to a UserControl from within its own Xaml

Is there a way 开发者_JAVA技巧to apply styles (specifically style data triggers) to a UserControl within it's own XAML code?


You cannot access a Style in xaml within the UserControl's resources - you have a few options tho:

  1. Set it in coding in the constructor through Style = FindResource(<name>) as Style
  2. Set it in the Parent control <local:MyUserControl Style="{StaticResource MyStyle}"
  3. Put the style in any Visual control's Resources-property 'up-the-chain' with an empty key and TargetType="{x:Type MyUserControl}"

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜