WPF控件应脱离父级的剪辑框

WPF控件应脱离父级的剪辑框,wpf,xaml,Wpf,Xaml,我正在寻找一种方法来打破WPF中父控件的剪辑框。例如: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="200" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <!-- This control should overlay the parent (the gri

我正在寻找一种方法来打破WPF中父控件的剪辑框。例如:

<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="200" />
    <ColumnDefinition Width="*" />
  </Grid.ColumnDefinitions>

  <!-- This control should overlay the parent (the grid) - is there a way to do this? -->
  <Rectangle Grid.Column="0" Width="400" />
</Grid>
如示例中所示,我想向可视化树添加一个控件,它应该覆盖父控件。我玩过Cliptobunds和ZIndex,但它们似乎没有影响。矩形始终被剪裁到网格的列

这在WPF中是可能的,还是我必须将它添加到可视化树的其他地方

谢谢,

这是:

由以下xaml生成

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="200" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>


    <Rectangle Grid.Column="0" Width="400" Grid.ColumnSpan="2" Fill="#FFBD3A3A" />
    <!-- This control overlays the parent control -->
    <Canvas Background="Blue" Width="55" Height="55" Grid.Column="1" Margin="226,124,37,140"></Canvas>
</Grid>

我建议不要使用这种方法并以不同的方式布置控件,但画布控件正是您所需要的。

在Ractangle上设置Grid.ColumnSpan=2。谢谢。也许这个例子太具体了。我需要以一种同样适用于其他父控件的方式打破父控件的剪切框。将矩形和网格或任何其他面板放在外部网格中彼此重叠。是的,在WPF中也可以这样做。实际上,你能想到的任何关于用户界面的事情都可以在WPF中完成,如果你怀疑的话,除了挑战。了解WPF的机理是完全不同的;然而,公平地说,我相信与我们必须使用的任何其他模式相比,它是实现UI设计模式飞跃的最佳逻辑。所以,也就是说,有很多方法可以实现你想要的。。。最简单的答案可能是将矩形放在网格之外。如果您提供更多XAML和您想要的图像,我们可以提供选项和答案。谢谢!这正是我想要的:-