如何隐藏WPF网格溢出(如CSS溢出:隐藏)

时间:2011-08-01 12:13:06

标签: c# wpf xaml grid overflow

我目前正在创建一个地铁风格的应用程序。 因此,我需要将我的客户区扩展到窗口以绘制阴影。 现在的问题是我有一个设置为Margin =“0,0,15,15”的按钮,当然它也会在这个阴影区域中绘制自己。我怎么能隐藏这个?在CSS中我只是将overflow:hidden应用于“Content”或UserControl。

problem

基本的WPF结构是这样的:

<Grid x:Name="LayoutRoot" SnapsToDevicePixels="True" Margin="15" Background="White">
    <Grid.Effect>
        <DropShadowEffect ShadowDepth="0" BlurRadius="15" Direction="470"/>
    </Grid.Effect>
        <Grid x:Name="Content">
        <UserControl></UserControl> // This is where the arrow button is with Margin="0,0,15,15"
    </Grid>
</Grid>

1 个答案:

答案 0 :(得分:34)

通常,您可以使用某个容器并将其ClipToBounds设置为true