【问题标题】:ASP.NET WPF - Image Overflowing border with corner radiusASP.NET WPF - 带有圆角半径的图像溢出边框
【发布时间】:2019-12-23 12:49:16
【问题描述】:

我在我的 ASP.NET WPF 项目中遇到问题,边框内的图像超出了边框限制。按照下面我的代码:

        <Border CornerRadius="20" Grid.Column="0" Grid.Row="0"  >
            <Button HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
                <Image Source="{Binding ImagePath}" />
            </Button>
        </Border>

【问题讨论】:

标签: c# asp.net wpf image cornerradius


【解决方案1】:

实际上,我找到了一种解决方法,比这种方法更简单

How to make the contents of a round-cornered border be also round-cornered?

这是我的解决方案:

<Border CornerRadius="20" Grid.Column="0" Grid.Row="0">
   <Button HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
   </Button>
   <Border.Background>
      <ImageBrush ImageSource="{Binding UploadImage}"/>
   </Border.Background>
</Border>

【讨论】:

    猜你喜欢
    • 2011-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多