首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法为目标元素找到控制FrameworkElement或FrameworkContentElement的方法。GradientStop

无法为目标元素找到控制FrameworkElement或FrameworkContentElement的方法。GradientStop
EN

Stack Overflow用户
提问于 2013-08-20 07:15:39
回答 1查看 2.7K关注 0票数 3

我有一个包含颜色的列表框,每个颜色都有7个标题,它是为颜色选择打印头。所以我的绑定变量是当选择打印头时,颜色框应该有这个样式。

代码语言:javascript
复制
<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')

EN

回答 1

Stack Overflow用户

发布于 2013-08-20 08:05:44

我相信你有这个问题,因为GradientStop不是FrameworkElement.来自MSDN:

代码语言:javascript
复制
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上的可冻结对象概述页面。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18329053

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档