在WPF中在网格上放置边框 [英] Put a border on the grid in 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屋!