Xamarin 表单,为 'Image' 控件添加边框颜色 Windows 8 应用程序

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

我正在使用 Xamarin Forms 开发移动应用程序,我想根据数据动态地为图像添加边框。

在 iOS、Android 应用程序中,使用 renderers,我可以添加边框颜色。

但是在Windows 8 应用程序上,我无法添加边框。我认为这是因为 System.Widows.Controls.Image 没有 属性 来设置边框粗细和边框颜色。

有什么方法可以在 Windows Phone 应用程序的 Renderer 上为图像添加边框?

我目前无法为您提供详细示例,但它应该是这样工作的:

为 Windows Phone 创建渲染器。在 OnElementChanged 方法覆盖中,您可以创建一个 'native' Windows Phone 边框元素,将图像添加到边框,然后调用 SetNativeControl(border);添加边框的方法,里面有图片。

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

        SetNativeControl(border);

我想你也可以使用 Xamarin.Forms.Frame 并放置在你的图像中

 <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>