如何绑定渐变停止颜色或GradientStops物业在Silverlight? [英] How to bind GradientStop Colours or GradientStops Property in Silverlight?

查看:798
本文介绍了如何绑定渐变停止颜色或GradientStops物业在Silverlight?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够有在Silverlight动态梯度,例如如下:

I want to be able to have a dynamic Gradient in Silverlight, such as below:

<RadialGradientBrush GradientOrigin="0.20,0.5" Center="0.25,0.50" 
                     RadiusX="0.75" RadiusY="0.5">
  <GradientStop Color="{Binding Path=GradientStart}" Offset="0" />
  <GradientStop Color="{Binding Path=GradientEnd}" Offset="1" />
</RadialGradientBrush>

我结合这两种性能返回类型为颜色,然而我总是得到这样的信息:

I am binding to two properties which return the type "Color" however I always get this message:

AG_E_PARSER_BAD_PROPERTY_VALUE

如果我尝试绑定到一个渐​​变停止收集这也有同样的问题,该如何解决这个问题:

If I try to bind to a GradientStop Collection this also has the same problem, what is the solution to this problem that:


  1. 允许的开始和一个渐变的结束在运行时更改

  2. 作品在Silverlight 3.0,而不是一个WPF的解决方案

如果有周围或反正工作重复这种行为,这将是可以接受的,我有一个与LinearGradients我可以只绑定出头填充​​属性来此工作的解决方案 - 但在这种情况下,将无法正常工作,再加上可能还有其他类型的梯度我可以用和其他人可能在未来使用该解决方案/替代将应用。

If there is a work around or anyway to duplicate this behaviour this would be acceptable, I have solutions that work with LinearGradients as I can just bind somethings "Fill" property to this - however in this situation that won't work, plus there may be other gradient types I may use and others may use in future which this solution / alternative will apply to.

推荐答案

的问题是,渐变停止不派生自 FrameworkElement的因此不能绑定数据。不幸的是,这意味着你必须从code设置。

The problem is that GradientStop does not derive from FrameworkElement therefore cannot be data bound. Unfortunately that means you have to set it from code.

这篇关于如何绑定渐变停止颜色或GradientStops物业在Silverlight?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆