简体   繁体   English

网格单元内stackpanel上的边框

[英]Border on stackpanel inside grid cell

I am trying to apply rounded corners to a Stackpanel that is located inside a grid cell. 我正在尝试将圆角应用于位于网格单元内部的Stackpanel。 I'm using a tag with CornerRadius. 我正在使用CornerRadius标签。 Instead of having the border surround the stackpanel, it instead stretches to surround the parent grid cell. 边框没有包围边框,而是拉伸以包围父网格单元。 Like this: 像这样:

截图

I use the following XAML: 我使用以下XAML:

<Border Grid.Row="0" Grid.Column="1" BorderBrush="#FF252A30" CornerRadius="5,5,5,5" BorderThickness="2,2,2,2">
    <StackPanel Grid.Row="0" Grid.Column="1" x:Name="stackpanelContactlist" Height="336" Margin="0,113,43,113" Background="#FF252A30" d:LayoutOverrides="Width">

        Content of Stackpanel       

    </StackPanel></Border></Grid>

I'm quite new to WPF, so I'm betting it's something simple - Anyone have any suggestions on how to fix this, so the rounded borded gets applied to the child stackpanel instead of the parent grid cell? 我对WPF还是很陌生,所以我敢打赌,这很简单-任何人都对如何解决此问题有任何建议,因此四舍五入的无聊对象将应用于子堆栈面板而不是父网格单元吗?

Thanks on advance. 提前谢谢。

Just move the margin attribute ( Margin="0,113,43,113" ) from StackPanel to the border. 只需将margin属性( Margin="0,113,43,113" )从StackPanel移动到边框。

Also you can remove Grid.Row="0" Grid.Column="1" from the stack panel as these are not needed there. 您也可以从堆栈面板中删除Grid.Row="0" Grid.Column="1" ,因为那里不需要这些。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM