Search code examples
c#wpfwindows-phonefillellipse

WPF Ellipse with BackgroundColor and Image


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?

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.


Solution

  • 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.