将BitmapIcon放在UWP应用程序的Ellipse元素中

问题描述 投票:0回答:1

在我的UWP应用程序中,我希望在Ellipse元素中放置一个位图图标。有没有办法使用Ellipse的Fill属性,或任何其他方式来实现这一点?

我只想使用Bitmap Icon,因为我需要使用Foreground属性更改图标的颜色。有没有办法可以使用BitmapIcon创建一个ImageBrush,因为这样可以让我用ImageBrush填充Ellipse,并帮助我实现UI描述。

c# windows uwp win-universal-app uwp-xaml
1个回答
1
投票

Ellipse是一个Shape对象,因此不能有内容或儿童。但是如果你想把你的BitmapIcon放在椭圆形的Control中,那么我认为你应该使用Border Control。

Border控制有CornerRadius财产。使用它,你可以将它的形状变成椭圆形,甚至是圆形:

enter image description here

上面的输出是通过以下代码实现的:

<Border
    Width="200"
    Height="200"
    CornerRadius="100"
    BorderBrush="White"
    BorderThickness="1">

    <BitmapIcon 
        UriSource="ms-appx:///Assets/StoreLogo.png"
        Foreground="DodgerBlue"/>

</Border>

这满足了你的需求吗?

© www.soinside.com 2019 - 2024. All rights reserved.