gpt4 book ai didi

c# - 如何在wpf中隐藏面板后面的项目

转载 作者:太空宇宙 更新时间:2023-11-03 18:27:37 24 4
gpt4 key购买 nike

我使用了下面的代码来控制显示

<Window x:Class="WpfApplication29.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid >
<Border Margin="100" BorderThickness="3" BorderBrush="Black">
<Canvas>
<Label Content="This is test" FontSize="129" Width="400" Height="200"/>
</Canvas>
</Border>
</Grid>
</Window>

enter image description here

如果它是 size,我想将它显示为从下方截取的第二个大于 parent control或者如果 margin is negative

最佳答案

您只需要为边框使用 ClipToBounds="True" 属性

 <Grid >
<Border Margin="100" BorderThickness="3" BorderBrush="Black" ClipToBounds="True">
<Canvas >
<Label Content="This is test" FontSize="129" Width="400" Height="200"/>
</Canvas>
</Border>
</Grid>

关于c# - 如何在wpf中隐藏面板后面的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30588644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com