开发者

Apply gradient to stack panel Background color/Images in silverlight

If I use in a stack panel I can only give color background to stack panel using LinearGradie开发者_如何学Cnt but can't add other element on it.

Any Idea how can I do this?

Thanx


Not sure how you manage to get that to fail. There is a super simple (ableit ugly gradient). Works fine:-

    <StackPanel>
        <StackPanel.Background>
            <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                <GradientStop Color="Black" Offset="0" />
                <GradientStop Color="#FFC95AFF" Offset="0.484" />
                <GradientStop Color="#FF3E5E7F" Offset="0.242" />
            </LinearGradientBrush>
        </StackPanel.Background>
        <TextBlock Foreground="White" Text="Hello World" />
    </StackPanel>


Probably the easiest best way to apply a gradient to a StackPanel is to contain it within a Border:

<Border>
  <Border.Background>
    ... you gradient goes here ...
  </Border.Background>

  <StackPanel>
    .. your content goes here ...
  </StackPanel>
</Border>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜