在WPF中在网格上放置边框 [英] Put a border on the grid in WPF

查看:61
本文介绍了在WPF中在网格上放置边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Grid上放置Border而不用Border元素包围Grid?

Is there a way to put a Border on the Grid without surrounding the Grid with the Border element?

<Border Margin="{Binding ElementName=thisUserControl, Path=PrintMargin}"
        BorderThickness="{Binding ElementName=thisUserControl, 
                             Path=PrintMarginThickness}"
        BorderBrush="LightGray">
    <Grid x:Name="mainGrid"
          Background="{Binding ElementName=thisUserControl, Path=Background}" />
</Border>

我可以在网格上使用"BitmapEffect"之类的东西吗? 我只需要在WpfUserControl上显示或不显示一个名为"PrintMargin"的边框即可.

Could I use something like "BitmapEffect" on the grid or stuff like this? I just need to display or not a border named "PrintMargin" on my WpfUserControl...

该边框是否应该可见,也许我还需要控制其厚度,以及颜色(画笔)...

This border should or not be visible and also perhaps I need to control its Thickness and maybe Color(Brush)...

推荐答案

按照您提到的方式(网格边界)没有发现任何问题,但是如果您确实希望,可以在最后添加Border Grid中的元素:

Don't see anything wrong with doing the way you mentioned (border around the grid), but if you really want you can add Border as a last element in your Grid:

<Grid>
    .. other elements ..
    <Border BorderBrush="DeepPink" BorderThickness="1" />
</Grid>

这篇关于在WPF中在网格上放置边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆