skip to Main Content

I’d like to know if there is a way to add a Border inside an image. I want something like the “Stroke” effect in Photoshop when the position is set to inside, i.e. it has to be painted over the image. Is it possible?

Thank you.

3

Answers


  1. You could place the border on top of the image :

    <Grid>
     <Image/>
     <Border/>
    </Grid>
    

    If you have set a CornerRadius, and you want to hide the Image in the corners, that’s more complicated, but you could set another almost same Border as the OpacityMask to your Image :

    <Grid>
        <!-- I used Rectangle instead of Image for the example -->
        <Rectangle Width="50" Height="50" Fill="Red">
            <Rectangle.OpacityMask>
                <VisualBrush>
                    <VisualBrush.Visual>
                        <Border Width="50" Height="50" Background="Black" 
                                CornerRadius="10"/>
                    </VisualBrush.Visual>
                </VisualBrush>
            </Rectangle.OpacityMask>
        </Rectangle>
    </Grid>
    
    Login or Signup to reply.
  2. Yes you could do a multilayer approach!

    <Grid>
        <Image />
        <Border horizontalAlignment="Stretch" verticalAlignment="Stretch" />
    </Grid>
    

    Remind the attributes you need to use, this is just a lightweight version!

    Login or Signup to reply.
  3. That’s easy i think

    <Grid>
        <Image />
        <Border/>
    </Grid>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search