English 中文(简体)
银光嵌套样式
原标题:Nesting Styles in Silverlight

我创建了一个 KPI 喜欢的控件, 并且想要根据特定的标准应用多个样式, 无需通过多个控件 。 基本上我拥有 :

<Border>
  <TextBlock>
</Border>

边框需要和 TextBlock 一样的样式。 我有典型的绿色/ 黄色/ 红色 KPI, 但每种都有两种模式。 您越接近最后期限, 越极端 。

因此,对于长期绿色,边框将具有绿色边框 w/ 透明背景, TextBlock 的字体颜色将是绿色的。 但是对于短期绿色, 我想让边框暗绿色, 以及 TextBlock 白色的字体颜色 。

显然,我可以用自定义代码来做到这一点, 并处理根据具体标准来设置风格, 但这种混乱(有些KPIs有多个文本锁 ) 。

有可能吗?

最佳回答

WPF有这个确切原因的数据触发器, 但不幸的是,他们没有把它变成银灯。

这可能是非常规的, 但是您可以将样式属性绑绑到 KPI 状态中, 然后使用自定义转换器, 该转换器返回正确的样式资源以获取相应的状态值 。

否则,海关编码是唯一的其他选择。

问题回答

暂无回答




相关问题
Creating a Style in code behind

Does anyone know how to create a wpf Style in code behind, I can t find anything on the web or MSDN docs. I have tried this but it is not working: Style s = new Style(typeof(TextBlock)); s....

WPF Custom Themes

I have a simple question which is giving me some difficulty. I have downloaded a custom them for WPF of the net. Now i want to apply this theme to my App instead of the default one. How do i do that,...

Is it sometimes bad to use <BR />?

Is it sometimes bad to use <BR/> tags? I ask because some of the first advice my development team gave me was this: Don t use <BR/> ; instead, use styles. But why? Are there negative ...

WPF - How to apply effect to a cropped image?

I have an Image being clipped like so: <Image Width="45" Grid.Column="0" Source="{Binding Photo}"> <Image.Clip> <RectangleGeometry Rect="0,0,45,55" RadiusX="8" RadiusY="8" /...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the ...

热门标签