wpfmarginellipseimagebrush

WPF apply margin on ImageBrush in Ellipse?


Please take a look at my following code:

<Grid>
    <Ellipse StrokeThickness="2" Stroke="White">
        <Ellipse.Fill>
            <ImageBrush ImageSource="someImage.png"/>
        </Ellipse.Fill>
    </Ellipse>
</Grid>

What I'm trying to do is to margin the someImage.png 5px from left and 5px from top. I'm wondering if it's possible as I couldn't find any margin property available.


Solution

  • You could put two Ellipses on top of each other like so:

        <Grid>
            <Ellipse StrokeThickness="2" Stroke="White"/>
            <Ellipse Margin="5" StrokeThickness="2" Stroke="White">
                <Ellipse.Fill>
                    <ImageBrush ImageSource="someImage.png"/>
                </Ellipse.Fill>
            </Ellipse>
        </Grid>
    

    The grid will put all the items in the same row/column on top of each other.