bashahul
bashahul

Reputation: 422

Xamarin form, Add border color for 'Image' Control for Windows 8 application

I am developing a mobile application using Xamarin Forms, I want to add borders to the image dynamically based on data.

On iOS, Android applications, using renderers, I can add border colors.

But on Windows 8 application, I cannot add the border. I think it is because of System.Widows.Controls.Image does not have a property to set the borders thickness and border color.

is there any way to add the border to the image on Renderer of Windows Phone application?

Upvotes: 1

Views: 2858

Answers (2)

viktormark92
viktormark92

Reputation: 111

I think you also can use Xamarin.Forms.Frame and place inside your image

 <Frame BorderColor="Orange" CornerRadius="20" Grid.Row="0" Grid.Column="1"  Margin="0,40,0,10"        
               HasShadow="True">
            <Image x:Name="AppLogoImage" Source="logo_ApplicationStartLogo.png"/>
        </Frame>

Upvotes: 1

ChristiaanV
ChristiaanV

Reputation: 5541

I'm currently not able to provide you a detailed example, but this is how it should work:

Create a renderer for Windows Phone. In the OnElementChanged method override you can create a 'native' Windows Phone border element, add the image to the border and after that call the SetNativeControl(border); method to add the border with the image inside it.

        var border = new Border() {BorderBrush = Colors.Red, BorderThickness = new Thickness(10)};
        border.Child = new Image();

        SetNativeControl(border);

Upvotes: 2

Related Questions