【问题标题】:Display a line at grids background在网格背景处显示一条线
【发布时间】:2012-08-10 13:49:30
【问题描述】:

如何在网格容器的背景中存储和显示一条线? 我必须为每个资源字典设置背景。

<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 进行造型。我不能使用图片,因为我必须在运行时/为每个应用程序设置颜色。

【问题讨论】:

  • 你能展示一些 XAML 并解释一下你想要做什么吗?你想要这条线在哪里?垂直的?水平的?一条线?多行?以某种方式与网格对齐?
  • 我有一个网格,它覆盖了我的网格的标准样式。问题是,我必须为窗口的每个应用程序的整个背景设置颜色,并绘制一条垂直线,该线设置在底部并具有我的代码的窗口宽度,请参阅我的帖子...我已经编辑了
  • 是否有一个选项可以将窗口的背景设置为一种颜色并设置在行上?网格的想法不是一个好主意,我认为^^

标签: c# wpf xaml styles


【解决方案1】:

您可以使用画笔本身。

使用visualbrush你可以画任何东西作为画笔:http://msdn.microsoft.com/de-de/library/system.windows.media.visualbrush.aspx

做这样的事

<VisualBrush>
...
<Grid Background="Red" .../>
<Line ... />

</VisualBrush>

【讨论】:

  • 也就是说,我如何在窗口的 xaml 中使用它....我是,我不能在单独的资源字典中使用它
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-28
  • 1970-01-01
  • 1970-01-01
  • 2023-03-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多