WPF apply margin on ImageBrush in Ellipse?

1.6k views Asked by At

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.

1

There are 1 answers

3
Iain On BEST ANSWER

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.