3
votes

I have a list box contains Colors and Each Color have 7 Heads it is to choose Print Head for Color. so my Binding variable is when print head is selected , Color box should have this Styles.

<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>

and My error is :

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
Can you provide some more details? For instance the actual element you are styling and the nature of the model used in the binding. - meilke

1 Answers

1
votes

I believe that you have this problem because GradientStop is not a FrameworkElement... from MSDN:

System.Object 
  System.Windows.Threading.DispatcherObject
    System.Windows.DependencyObject
      System.Windows.Freezable
        System.Windows.Media.Animation.Animatable
          System.Windows.Media.GradientStop

If you notice the extended System.Windows.Freezable class above, then you will see that this class is also 'freezable'... this means that it cannot be modified. See the Freezable Objects Overview page at MSDN for more information.