See Also: BoxView Members
BoxView is a useful stand-in for images or custom elements when doing initial prototyping. BoxView has a default size request of 40x40. If you need a different size, assign the VisualElement.WidthRequest and VisualElement.HeightRequest properties.
The Xamarin.Forms.BoxView class has the following XAML properties:
| Property | Value |
|---|---|
| Color | A color specification, with or without the prefix, "Color". For example, "Color.Red" and "Red" both specify the color red. |
The example below creates a red Xamarin.Forms.Boxview with the default width and height.
XAML Example
<BoxView Color="Red" />
The following example shows a basic use:
C# Example
using System;
using Xamarin.Forms;
namespace FormsGallery
{
class BoxViewDemoPage : ContentPage
{
public BoxViewDemoPage()
{
Label header = new Label
{
Text = "BoxView",
Font = Font.BoldSystemFontOfSize(50),
HorizontalOptions = LayoutOptions.Center
};
BoxView boxView = new BoxView
{
Color = Color.Accent,
WidthRequest = 150,
HeightRequest = 150,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
// Accomodate iPhone status bar.
this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
// Build the page.
this.Content = new StackLayout
{
Children =
{
header,
boxView
}
};
}
}
}
