我有一个包含颜色的列表框,每个颜色都有7个标题,它是为颜色选择打印头。所以我的绑定变量是当选择打印头时,颜色框应该有这个样式。
<Setter TargetName="colorSelectionRectangle" Property="Fill">
<Setter.Value>
<LinearGradientBrush SpreadMethod="Repeat" StartPoint="0,0" EndPoint="25,25">
<LinearGradientBrush.RelativeTransform>
<ScaleTransform ScaleX="0.01" ScaleY="0.01" />
</LinearGradientBrush.RelativeTransform>
<GradientStop Offset="0" Color="White" />
<GradientStop Offset="0.5" Color="White" />
<GradientStop Offset="0.5" Color="{Binding [0].Item.PrintColor.Argb}" />
<GradientStop Offset="1" Color="{Binding [0].Item.PrintColor.Argb}" />
</LinearGradientBrush>
</Setter.Value>
我的错误是:
System.Windows.Data错误:2:找不到控制目标元素的FrameworkElement或FrameworkContentElement。BindingExpression:Path=.Item.PrintColor.Argb;DataItem=null;目标元素是'GradientStop‘(HashCode=52327179);目标属性是'Color’(键入'Color')
发布于 2013-08-20 08:05:44
我相信你有这个问题,因为GradientStop不是FrameworkElement.来自MSDN:
System.Object
System.Windows.Threading.DispatcherObject
System.Windows.DependencyObject
System.Windows.Freezable
System.Windows.Media.Animation.Animatable
System.Windows.Media.GradientStop如果您注意到上面扩展的System.Windows.Freezable类,那么您将看到这个类也是“可冻结的”.这意味着它不能被修改。有关更多信息,请参见MSDN上的可冻结对象概述页面。
https://stackoverflow.com/questions/18329053
复制相似问题