wpf - 使用负边距时在控件内显示内容。

标签 wpf xaml winrt-xaml

例如我有2个Grid,像这样:

<Grid  Height="200" Width="200" Background="Red">
    <Grid HorizontalAlignment="Left" Height="100" Width="100" Background="Blue" Margin="-30,0,0,0" />
</Grid>

结果看起来:

enter image description here

如何创建在使用负边距时仅在控件内部显示的内容?
像这样:

enter image description here

最佳答案

您是否尝试过使用此处描述的剪辑:

http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.uielement.clip.aspx

像这样:

    <Grid  Height="200" Width="200" Background="Red">
        <Grid.Clip>
            <RectangleGeometry Rect="0,0,200,200" />
        </Grid.Clip>
        <Grid HorizontalAlignment="Left" Height="100" Width="100" Background="Blue" Margin="-30,0,0,0" />
    </Grid>

关于wpf - 使用负边距时在控件内显示内容。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20519957/

相关文章:

xaml - 在鼠标悬停时使按钮透明

c# - WinRT中ListView的item插入动画

c# - 关闭非按钮弹出窗口?

.net - 在 MVVM 中实现逻辑验证的好方法是什么?

c# - 访问控件 - 缺少 using 指令或程序集引用

xaml - 带有 XAML 元素 header 的 ScrollViewer 中的 WebView

wpf - 创建一个方形用户控件

c# - Caliburn Micro - 文本框中的文本不会显示

c# - ComboBox 绑定(bind)中断对 SelectedItem 中对象的更改

ios - 防止 Xamarin.Forms.iOS 中的编辑器自动滚动