WPF椭圆与BackgroundColor和图像

时间:2022-06-22 23:40:55

I'm developing a Windows Phone application and I have some Ellipses. Is it possible to have a background image on them AND a background color?

我正在开发一个Windows Phone应用程序,我有一些省略号。是否可以在它们上面有背景图像和背景颜色?

When I looked for it, VS only allows me to change the Fill property with an image but didn't allow me to keep the Color on Fill + the Image.

当我查找它时,VS只允许我用图像更改Fill属性,但不允许我保持填充颜色+图像。

2 个解决方案

#1


9  

Just use two ellipses, overlapping each other:

只需使用两个相互重叠的椭圆:

<Grid>
    <Ellipse Width="100" Height="60" Fill="Navy" />
    <Ellipse Width="100" Height="60">
        <Ellipse.Fill>
            <RadialGradientBrush>
                <GradientStop Color="#00FF0000" Offset="0" />
                <GradientStop Color="#FFFF0000" Offset="1" />
            </RadialGradientBrush>
        </Ellipse.Fill>
    </Ellipse>
</Grid>

Change the fill property of the second to use your image.

更改第二个的填充属性以使用您的图像。

#2


2  

try this:

<Ellipse>
  <Ellipse.Fill>
    <ImageBrush ImageSource="/myimage.png" Stretch="Fill"></ImageBrush>
  </Ellipse.Fill>
</Ellipse>

#1


9  

Just use two ellipses, overlapping each other:

只需使用两个相互重叠的椭圆:

<Grid>
    <Ellipse Width="100" Height="60" Fill="Navy" />
    <Ellipse Width="100" Height="60">
        <Ellipse.Fill>
            <RadialGradientBrush>
                <GradientStop Color="#00FF0000" Offset="0" />
                <GradientStop Color="#FFFF0000" Offset="1" />
            </RadialGradientBrush>
        </Ellipse.Fill>
    </Ellipse>
</Grid>

Change the fill property of the second to use your image.

更改第二个的填充属性以使用您的图像。

#2


2  

try this:

<Ellipse>
  <Ellipse.Fill>
    <ImageBrush ImageSource="/myimage.png" Stretch="Fill"></ImageBrush>
  </Ellipse.Fill>
</Ellipse>