网格单元内堆栈面板上的边框
我正在尝试将圆角应用于位于网格单元内部的 Stackpanel。我正在使用带有 CornerRadius 的标签。它不是让边框包围堆栈面板,而是拉伸以包围父网格单元。像这样:
我使用以下 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>
我对 WPF 很陌生,所以我打赌这很简单- 任何人对如何解决此问题有任何建议,以便将圆角边框应用于子堆栈面板而不是父网格单元?
提前致谢。
I am trying to apply rounded corners to a Stackpanel that is located inside a grid cell. I'm using a tag with 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:
<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?
Thanks on advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将 margin 属性 (
Margin="0,113,43,113"
) 从 StackPanel 移至边框即可。您还可以从堆栈面板中删除
Grid.Row="0" Grid.Column="1"
,因为那里不需要这些。Just move the margin attribute (
Margin="0,113,43,113"
) from StackPanel to the border.Also you can remove
Grid.Row="0" Grid.Column="1"
from the stack panel as these are not needed there.