在 XAML Silverlight 中将背景颜色应用于整个网格行
我正在尝试将渐变背景应用于我创建的 XAML Silverlight 网格中的一行。
我可以毫无困难地做这样的事情:
<Grid>
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<!-- components and various stuffs -->
</Grid>
不幸的是,这将渐变应用于整个网格。
似乎我无法将渐变(甚至颜色)应用于网格中的单个行定义。是否可以?
谢谢!
I'm trying to apply a gradient background to just one row in a XAML Silverlight grid that I've created.
I can do something like this without any trouble:
<Grid>
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<!-- components and various stuffs -->
</Grid>
Unfortunately this applies the gradient to the entire grid.
It seems as though I can't apply a gradient (or even a color) to an individual row definition in the grid. Is it possible?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
边框
,然后使用
Grid.Row
和Grid.ColumnSpan
将其放入您要设置的Grid
的特定行中想。Use a
Border
, and then useGrid.Row
andGrid.ColumnSpan
to put it in the specific row of theGrid
that you want.如果要模拟垂直顺序的两种颜色,还可以使用 Offset 属性。如果将这两个设置为相同的值,您将得到以下模拟:
你还可以做更多:)
If you want to simulate two colors in vertical order, you can also use the Offset property. If you set these two on the same value, you get this simulation:
You can do even more :)