2013-08-20 20 views
2

我有一個列表框包含的顏色和每種顏色有7個頭是選擇打印頭的顏色。所以我的Binding變量是當打印頭被選中時,顏色框應該有這種樣式。找不到管理目標元素的FrameworkElement或FrameworkContentElement。 GradientStop

<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 Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=[0].Item.PrintColor.Argb; DataItem=null; target element is 'GradientStop' (HashCode=52327179); target property is 'Color' (type 'Color')

+1

你能提供更多的細節嗎?例如,您正在設計的實際元素以及綁定中使用的模型的性質。 – meilke

回答

1

我相信你有這個問題,因爲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上的Freezable Objects Overview頁面。