5

在 WPF 中,我希望为我的电影创建圆角,但电影实际上会与边框重叠,我得到一个正常的矩形框来加载我的电影。知道如何解决这个问题吗? 在此处输入图像描述

<Border BorderBrush="#FF000000" BorderThickness="1,1,1,1" CornerRadius="20,20,20,20">
    <Grid>
        <MediaElement x:Name="movieLoader" HorizontalAlignment="Left" Height="128" VerticalAlignment="Top" Width="236" Source="../video/empty.mp4"/>
    </Grid>
</Border>
4

2 回答 2

3

试试这个:

<Border x:Name="border" BorderThickness="1" BorderBrush="#FF000000" CornerRadius="20" Padding="1"
        HorizontalAlignment="Center" VerticalAlignment="Center">
    <Grid>
        <Border Name="mask" Background="White" CornerRadius="{Binding ElementName=border, Path=CornerRadius}"/>
        <Grid>
            <Grid.OpacityMask>
                <VisualBrush Visual="{Binding ElementName=mask}"/>
            </Grid.OpacityMask>
            <MediaElement x:Name="movieLoader" HorizontalAlignment="Left" Height="128" 
                          VerticalAlignment="Top" Width="236" Source="../video/empty.mp4"/>
        </Grid>
    </Grid>
</Border>
于 2013-08-31T09:10:08.957 回答
1

设置ClipToBoundsTrue

<Border ClipToBounds="True" BorderBrush="#FF000000" BorderThickness="1"
    CornerRadius="20">
    <Grid>
        <MediaElement x:Name="movieLoader" HorizontalAlignment="Left"
            Height="128" VerticalAlignment="Top" Width="236"
            Source="../video/empty.mp4"/>
    </Grid>
</Border>
于 2013-08-30T15:47:35.953 回答