Xamarin.Forms.BoxView Class
A Xamarin.Forms.View used to draw a solid colored rectangle.

See Also: BoxView Members

Syntax

public class BoxView : View

Remarks

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:
PropertyValue
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
                }
            };
        }
    }
}

Requirements

Namespace: Xamarin.Forms
Assembly: Xamarin.Forms.Core (in Xamarin.Forms.Core.dll)
Assembly Versions: 1.0.0.0, 1.1.0.0, 1.2.0.0, 1.3.0.0