我在ASP.NET WPF项目中遇到问题,边界内的图像溢出边界限制。按照下面的代码:
<Border CornerRadius="20" Grid.Column="0" Grid.Row="0" >
<Button HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
<Image Source="{Binding ImagePath}" />
</Button>
</Border>
答案 0 :(得分:0)
实际上,我找到了一种解决方法,可以解决这一问题,并且比以下方法更简单
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>