Search code examples
c#imageuwpwindows-phone

How can I set border to Image control in UWP XAML


How can I apply a rounded border to Image control in UWP xaml page so that this Image will also have rounded corners? I tried

<Border BorderBrush="White"
        BorderThickness="1"
        HorizontalAlignment="Center"
        Height="183"
        VerticalAlignment="Top"
        Width="316"
        Canvas.ZIndex="1">
    <Image x:Name="carImage"
           Height="183"
           VerticalAlignment="Top"
           Width="306"
           HorizontalAlignment="Center"
           IsTapEnabled="False"
           IsRightTapEnabled="False"
           IsHoldingEnabled="False"
           IsDoubleTapEnabled="False"
           Stretch="UniformToFill"
           Margin="-1,-1,9,-1"/>
</Border>

But without success. Is there any way to do this or am I so blind I can't see an obvious solution? Thank you in advance.


Solution

  • This should work:

    <Border BorderBrush-"White"
            BorderThickness="1"
            CornerRadius="5"
            ... >
        <Border.Background>
            <ImageBrush ImageSource="image.png" .../>
        </Border.Background>
    </Border>