locked
Background's value can't set to the Gradient RRS feed

  • Question

  • Hi,
       I can't set a Gradient value for the Background property on the WinFx Nov. CTP, neither XamlPad nor VS. The code likes following could not work:

    <StackPanel Background="HorizontalGradient #000001 #0000E3" ></StackPanel>

    It isn't parsed in XamlPad and it isn't compiled in VS IDE.

    Is the property changed on this release? If so, where had the Gradient background gone?

    Thanks.
    Saturday, December 10, 2005 7:28 PM

Answers

  • You can't use the mini-language syntax anymore starting in the Nov. CTP (it has been removed). Instead you must use compound property syntax like so:

    <StackPanel ...>
      <StackPanel.Background>
        <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
          <LinearGradientBrush.GradientStops>
           <GradientStopCollection>
            <GradientStop Color="#FFFF0000" Offset="0"/>
            <GradientStop Color="#FFFFFFFF" Offset="1"/>
           </GradientStopCollection>
          </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
      </StackPanel.Background>
    </StackPanel>

    HTH,
    Drew
    Saturday, December 10, 2005 8:09 PM
  • The short hand notation for gradients is one of the mini-languages that have been removed for the Nov CTP.  You need to use the full object notation.  Something like:

    <StackPanel>
       <StackPanel.Background>
          <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
             <LinearGradientBrush.GradientStops>
                <GradientStop Color="#000001" Offset="0" />
                <GradientStop Color="#0000E3" Offset="1" />
             </LinearGradientBrush.GradientStops>
          </LinearGradientBrush>
       </StackPanel.Background>
       ...
    </StackPanel>

    Saturday, December 10, 2005 8:10 PM

All replies

  • You can't use the mini-language syntax anymore starting in the Nov. CTP (it has been removed). Instead you must use compound property syntax like so:

    <StackPanel ...>
      <StackPanel.Background>
        <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
          <LinearGradientBrush.GradientStops>
           <GradientStopCollection>
            <GradientStop Color="#FFFF0000" Offset="0"/>
            <GradientStop Color="#FFFFFFFF" Offset="1"/>
           </GradientStopCollection>
          </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
      </StackPanel.Background>
    </StackPanel>

    HTH,
    Drew
    Saturday, December 10, 2005 8:09 PM
  • The short hand notation for gradients is one of the mini-languages that have been removed for the Nov CTP.  You need to use the full object notation.  Something like:

    <StackPanel>
       <StackPanel.Background>
          <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
             <LinearGradientBrush.GradientStops>
                <GradientStop Color="#000001" Offset="0" />
                <GradientStop Color="#0000E3" Offset="1" />
             </LinearGradientBrush.GradientStops>
          </LinearGradientBrush>
       </StackPanel.Background>
       ...
    </StackPanel>

    Saturday, December 10, 2005 8:10 PM
  • Thanks Drew and Michael. I've got it.
    Saturday, December 10, 2005 8:17 PM