在网格背景上显示一条线 [英] Display a line at grids background
问题描述
如何在网格容器的背景中存储和显示一条线?我必须为每个资源字典设置背景.
How can I store and display a line at the background of a grid container? I had to set the background per resource dictionary.
<Style TargetType="{x:Type Grid}">
<Setter Property="Background">
<Setter.Value>
<!--here I had to display a vertical line at bottom,
which goes over the whole window -->
</Setter.Value>
</Setter>
</Style>
或:
<Style TargetType="{x:Type Window}">
<Setter Property="Background">
<Setter.Value>
<!-- here I had to display a vertical line at bottom,
which goes over the whole window and set the background color-->
</Setter.Value>
</Setter>
</Style>
问题是我在应用程序的每个窗口中都需要红色页脚.我使用 ResourceDictionary
进行样式设置.我不能使用图片,因为我必须在运行时/为每个应用程序设置颜色.
The problem is that I need the red footer in each window of the application. I use a ResourceDictionary
for styling. I can't use a picture, because I have to set the colors at runtime/for each application.
推荐答案
您可以使用画笔本身.
使用visualbrush,您可以将任何内容绘制为画笔:http://msdn.microsoft.com/de-de/library/system.windows.media.visualbrush.aspx
with the visualbrush you can draw anything as brush: http://msdn.microsoft.com/de-de/library/system.windows.media.visualbrush.aspx
做类似的事情
<VisualBrush>
...
<Grid Background="Red" .../>
<Line ... />
</VisualBrush>
这篇关于在网格背景上显示一条线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!