Xamarin Forms StackLayout with two Frames not filling up the screen - xamarin.forms

I see a very strange behavior that I can't understand. I am putting two Frames inside vertically oriented StackLayout. The first Frames' Vertical Option is set to StartAndExpand which renders correctly but the Second Frames' VerticalOption is set to FillAndExpand and for some strange reason it does not follow after the first Frame but from the middle of the screen. I want the Second Frame to immediately follow after the first Frame and take up the whole screen.
Code Below:
<RelativeLayout
x:Name="mainLayout"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}">
<StackLayout
Padding="5,5,5,5"
BackgroundColor="Transparent"
HorizontalOptions="FillAndExpand"
Orientation="Vertical"
Spacing="0"
VerticalOptions="FillAndExpand"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.88}" >
<Frame
OutlineColor="Silver"
BackgroundColor="#FFFFFF"
VerticalOptions="StartAndExpand"
HasShadow="False" >
<StackLayout
BackgroundColor="Transparent">
<RelativeLayout
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
HorizontalOptions="FillAndExpand">
<Label
x:Name="To_Label"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.2}"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0}"
FontSize="Micro"
TranslationY="7"
FontAttributes="Bold"
HorizontalOptions="FillAndExpand"
VerticalOptions="CenterAndExpand"
TextColor="#2A84D3"
Text="To:">
</Label>
<Controls:DoneEntry x:Name="To_Entry"
Text="{Binding Model.To}"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.22}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.70}"
VerticalOptions="CenterAndExpand"
HorizontalOptions="FillAndExpand" >
<CorcavBehaviors:Interaction.Behaviors>
<CorcavBehaviors:BehaviorCollection>
<PounceBehaviors:EntryTextChanged Command="{Binding ReceipientTextChangeCommand}"/>
</CorcavBehaviors:BehaviorCollection>
</CorcavBehaviors:Interaction.Behaviors>
</Controls:DoneEntry>
</RelativeLayout>
</StackLayout>
</Frame>
<Frame
OutlineColor="Silver"
BackgroundColor="#FFFFFF"
VerticalOptions="FillAndExpand"
HasShadow="False" >
<StackLayout
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
BackgroundColor="Transparent">
<Editor
Text="{Binding EmailContent}"
FontSize="Micro"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
>
<CorcavBehaviors:Interaction.Behaviors>
<CorcavBehaviors:BehaviorCollection>
<PounceBehaviors:EditorTextChanged Command="{Binding MessageTextChangedCommand}"/>
</CorcavBehaviors:BehaviorCollection>
</CorcavBehaviors:Interaction.Behaviors>
</Editor>
</StackLayout>
</Frame>
</StackLayout>
<RelativeLayout
Padding="5,5,5,5"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=.12}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.88}"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand">
<BoxView Color="#3E95D1" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}" HeightRequest="1" />
<Controls:SwipeRightButton x:Name="SendEmail_Button"
BackgroundColor="#2A84D3"
OutlineColor="Silver"
HasShadow="False"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.90}" >
<StackLayout x:Name="ImageLabelContainer"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.90}"
Orientation="Horizontal"
HorizontalOptions="CenterAndExpand">
<Image
x:Name="connect_icon"
Source="sendemailwhite"
Aspect="AspectFill"
BackgroundColor="Transparent"
VerticalOptions="Center"
HorizontalOptions="Center">
</Image>
<Label
VerticalOptions="Center"
HorizontalOptions="Center"
FontSize="Micro"
TextColor="#FFFFFF"
Text="Swipe to Send" />
</StackLayout>
</Controls:SwipeRightButton>
</RelativeLayout>
</RelativeLayout>

Found the problem. The first Frames' VerticalOption should be Start instead of StartAndExpand.

Related

How does one position elements in RelativeLayout in Xamarin?

I relation to my question No property, BindableProperty, or event found for “HeightRequest”, or mismatching type between value and property error in Xamarin.Forms, is there any way I can place the username and password entry elements right below the Welcome Label?
So, basically, the app should look like:
[Welcome Label]
[username]
[password]
[login]
I tried using
<RelativeLayout>
<Label
Text="Welcome"
BackgroundColor="Yellow"
TextColor="Green"
FontSize="Medium"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Factor=1, Property=Width, Constant=0}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Factor=0.1, Property=Height, Constant=0}"
/>
<Entry
Text="Username"
IsPassword="False"
/>
</RelativeLayout>
(Currently just the username field) but to no avail. Why is the entry field being placed over the label?
You could use RelativeToView property to indicate a constraint that is relative to a view
<RelativeLayout>
<Label
x:Name="label"
Text="Welcome"
BackgroundColor="Yellow"
TextColor="Green"
FontSize="Medium"
WidthRequest="100"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Factor=1, Property=Width, Constant=1}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Factor=0.1, Property=Height, Constant=0}"
/>
<Entry
x:Name="name"
Text="Username"
IsPassword="False"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=label,Property=Width,Factor=0.50,Constant=-50}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=label,Property=Y ,Constant=200}"
/>
<Entry
x:Name="password"
Text="Password"
IsPassword="False"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=name,Property=X}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=name,Property=Y ,Constant=50}"
/>
<Button Text="Login" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=password,Property=X}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=password,Property=Y ,Constant=200}"/>
</RelativeLayout>
effect like:
Try making something like this & change the alignment according to you.
<StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Label Text="Welcome" HorizontalOptions="Start" Margin="10, 30, 0, 0"/>
<Entry Placeholder="User Id" Margin="10, 20, 0, 0"/>
<Entry Placeholder="Password" IsPassword="True" Margin="10"/>
<Button Text="Login" HorizontalOptions="Center"/>
</StackLayout>
I used stack layout just for basic purpose, its not perfect UI but just for reference.

Running style app with side by side controls

I am using a stack layout as its the easiest with responsive but I am trying to get to items side by side I am trying to mimic running apps with speed and distance.
My Main question is how would one get the speed and distance to look similar to the design I can't get the spacing right in a stack layout
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="WellbeingNinja.Views.BmiInfo">
<ContentPage.Content>
<StackLayout Orientation="Horizontal" Spacing="0" Padding="0" VerticalOptions="StartAndExpand">
<Frame x:Name="frameTotalSpeed" CornerRadius="7" >
<StackLayout>
<Label x:Name="lblSpeedText" Text="Distance"></Label>
<Label x:Name="lblSpeed" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Text="0.00" FontSize="Large" ></Label>
</StackLayout>
</Frame>
<Frame x:Name="frameTotalDistance" CornerRadius="7">
<StackLayout>
<Label x:Name="lbldistanceText" Text="Distance"></Label>
<Label x:Name="lblDistance" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Text="0.00" FontSize="Large" ></Label>
</StackLayout>
</Frame>
I am trying to mimic this style here
use a Grid
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="50*" />
</Grid.ColumnDefinitions>
<Frame Grid.Column="0" x:Name="frameTotalSpeed" CornerRadius="7" >
<StackLayout>
<Label x:Name="lblSpeedText" Text="Distance"></Label>
<Label x:Name="lblSpeed" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Text="0.00" FontSize="Large" ></Label>
</StackLayout>
</Frame>
<Frame Grid.Column="1" x:Name="frameTotalSpeed" CornerRadius="7" >
<StackLayout>
<Label x:Name="lbldistanceText" Text="Distance"></Label>
<Label x:Name="lblDistance" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Text="0.00" FontSize="Large" ></Label>
</StackLayout>
</Frame>
</Grid>

Top positioned Xamarin forms listview with a header - problem: top position varies on some iPhone models

I need to set the height of the list view so that the bottom view cell is not cut off whenever adding or removing a view item. I can achieve it for some iPhone models, but not the others. It seems it’s not a right way to achieve it by iPhone model. My questions are:
1. On some iPhone models, why the top position shifts down by about 25 pixels after adding a view item?
2. How to find the absolute top position Y coordinate of the list view?
It seems AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" doesn’t help. VerticalOptions="Start" doesn’t help either.
Note:
1. no such an issue on Android phones.
2. Observation only: It seems that changing the margin of the listview header brandStack has no effect on the layout, eg. cannot see increased margins.
3. The following two screenshots show that the top position of the listview header has moved down a bit after an item is added to the listview.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="tecommobile.Views.PanelsHomePage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:effects="clr-namespace:tecommobile.Effects;assembly=tecommobile"
xmlns:tecommobile="clr-namespace:tecommobile;assembly=tecommobile"
xmlns:views="clr-namespace:tecommobile.Views;assembly=tecommobile"
xmlns:controls="clr-namespace:Flex.Controls;assembly=Flex"
xmlns:system="clr-namespace:System;assembly=netstandard"
x:Name="PanelHomePage"
Title="{Binding Title}"
BackgroundColor="Bisque"
NavigationPage.HasNavigationBar="false">
<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="addPanelStyle" TargetType="views:CustomImageButton" BasedOn="{StaticResource customImageButtonStyle}">
<Setter Property="Source" Value="panel_add.png" />
<Setter Property="HeightRequest" Value="70" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<RelativeLayout>
<tecommobile:GradientColorStack RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=1}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=1}"
Style="{StaticResource gradientColorStack}">
<StackLayout>
<StackLayout x:Name="panelListViewStack" BackgroundColor="Red"
AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All">
<ListView x:Name="ItemsListView" BackgroundColor="Orange"
Margin="15"
CachingStrategy="RecycleElement"
IsPullToRefreshEnabled="false"
ItemsSource="{Binding Items}"
RefreshCommand="{Binding LoadItemsCommand}"
SelectionMode="None"
Style="{StaticResource listViewNoSeparatorStyle}"
Scrolled="ItemsListView_OnScrolled">
<ListView.Header>
<StackLayout x:Name="brandStack" Margin="15, 0, 15, 0" HeightRequest="150" BackgroundColor="Yellow">
<Image HeightRequest="48"
HorizontalOptions="Center"
Source="Icon_ILXLinks.png"
WidthRequest="48"
Margin="0,30,0,0" />
<Label FontSize="20"
HorizontalTextAlignment="Center"
Text="TecomPlus"
TextColor="White"
VerticalTextAlignment="Center" />
<Label FontSize="14"
HorizontalTextAlignment="Center"
Text="Your smart security manager"
TextColor="White"
VerticalTextAlignment="Center"
Margin="0,0,0,20" />
</StackLayout>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid effects:RoundCornersEffect.CornerRadius="8" HeightRequest="75" Margin="2" BackgroundColor="{Binding PanelColour}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="6*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Image Grid.Row="0" Grid.Column="0" Source="{Binding BindingContext.EditToggleIcon, Source={x:Reference PanelHomePage}}"
BackgroundColor="Transparent" WidthRequest="50" HorizontalOptions="StartAndExpand" Margin="10,0,0,0">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Path=BindingContext.HomePageEditPanelCommand, Source={x:Reference PanelHomePage}}" CommandParameter="{Binding .}"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Label Grid.Row="0" Grid.Column="1" Text="{Binding Text}" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" VerticalOptions="FillAndExpand"
LineBreakMode="NoWrap" FontSize="14" TextColor="{Binding PanelTextColour}">
</Label>
<Image Grid.Row="0" Grid.Column="2" Source="forward.png" Style="{StaticResource rightImageStyle}">
</Image>
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Path=BindingContext.RunPanelCommand, Source={x:Reference PanelHomePage}}" CommandParameter="{Binding .}"
NumberOfTapsRequired="1" />
</Grid.GestureRecognizers>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout HeightRequest="70"></StackLayout>
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BackToEditCommand}"/>
</StackLayout.GestureRecognizers>
</StackLayout>
<tecommobile:GradientColorStack.GestureRecognizers>
<TapGestureRecognizer Command="{Binding BackToEditCommand}"/>
</tecommobile:GradientColorStack.GestureRecognizers>
</tecommobile:GradientColorStack>
<views:CustomImageButton Command="{Binding InfoCommand}" BackgroundColor="Transparent"
HeightRequest="30"
WidthRequest="30"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Width,
Factor=1,
Constant=-45}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Height,
Factor=0,
Constant=35}"
Source="info.png">
</views:CustomImageButton>
<Grid x:Name="bottomGrid" BackgroundColor="#216593" effects:RoundCornersEffect.CornerRadius="8"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-140}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-70}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.0*" />
<ColumnDefinition Width="1.0*" />
</Grid.ColumnDefinitions>
<Image x:Name="AddButton" Source="panel_add.png" Grid.Row="0" Grid.Column="0" Style="{StaticResource buttonImageStyle}">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding AddItemCommand}" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
<Image x:Name="DeleteButton" Source="{Binding BindingContext.DeleteToggleIcon, Source={x:Reference PanelHomePage}}"
Grid.Row="0" Grid.Column="1" Style="{StaticResource buttonImageStyle}">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ToggleDeleteIconCommand}" CommandParameter="{x:Reference DeleteButton}" NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
</Grid>
</RelativeLayout>
</ContentPage.Content>
</ContentPage>
The top position shifts down because the margin you set in the listView:
<ListView BackgroundColor="Orange" Margin="15">
Remove the Margin="15" and the space will disappear.
BTW, you can add page-safe-area-layout to make it looks better:
<ContentPage ...
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
Title="Safe Area"
ios:Page.UseSafeArea="true">
<StackLayout>
...
</StackLayout>
</ContentPage>

Floating Button with Numeric Count Value in Xamarin Forms

Unable to add the numeric part to the Floating Button
Just an idea of layouting frame inside RealtiveLayout, do change as per your need.
<RelativeLayout
VerticalOptions="Start"
HorizontalOptions="Start"
Margin="0,30,0,0"
HeightRequest="75"
WidthRequest="75"
IsClippedToBounds="False">
<RelativeLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
</RelativeLayout.GestureRecognizers>
<Frame
x:Name="floatMainButton"
Padding="0"
HeightRequest="75"
CornerRadius="38"
WidthRequest="75"/>
<Frame
BackgroundColor="LightBlue"
HeightRequest="25"
WidthRequest="25"
Padding="0"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=floatMainButton, Factor=0.75, Property=Width}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=floatMainButton, Factor=-0.10, Property=Height}"
CornerRadius="13">
<Label
VerticalOptions="Center"
HorizontalOptions="Center"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
TextColor="White"
Text="{Binding Count}"/>
</Frame>
</RelativeLayout>
Is this what you are looking for
Comment for any query...

RelativeLayout in Xamarin: Can't make a square

I've grabbed the sample project from here: https://developer.xamarin.com/samples/xamarin-forms/BoxView/ListViewColors/
I'm trying to make visual changes, in particular I'm trying to get the color squares to be rounded circles. The color squares are BoxViews in the original, and they use WidthRequest and HeighRequest, both set to 50. This succeeds in making them square. But:
BoxViews don't have a CornerRadius property, so I've made them Frames instead.
I don't want to use points, I want to use RelativeLayout values, so I've tried to set both width and height using Factor=0.1 of the ItemTemplate's Frame.
It doesn't work! No matter what I do, the colored frames are just a weird oblong shape--they're not even square anymore.
What am I doing wrong?
<ListView SeparatorVisibility="None"
BackgroundColor="Transparent"
ItemsSource="{x:Static local:NamedColor.All}"
RelativeLayout.WidthConstraint="{ConstraintExpression
Type=RelativeToParent,
Property=Width,
Factor=1}">
<ListView.RowHeight>
<OnPlatform x:TypeArguments="x:Int32">
<On Platform="iOS, Android" Value="80" />
<On Platform="UWP" Value="90" />
</OnPlatform>
</ListView.RowHeight>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ContentView Padding="5">
<Frame x:Name="itemFrame"
BackgroundColor="#bbffffff"
Padding="8"
CornerRadius="10"
HasShadow="false">
<StackLayout Orientation="Horizontal">
<Frame x:Name="colorFrame"
CornerRadius="20"
OutlineColor="Transparent"
BackgroundColor="{Binding Color}"
HasShadow="false"
RelativeLayout.WidthConstraint="{ConstraintExpression
Type=RelativeToView,
ElementName=itemFrame,
Property=Width,
Factor=0.1}"
RelativeLayout.HeightConstraint="{ConstraintExpression
Type=RelativeToView,
ElementName=itemFrame,
Property=Width,
Factor=0.1}"/>
<StackLayout>
<Label Text="{Binding FriendlyName}"
FontSize="22"
VerticalOptions="StartAndExpand" />
<Label Text="{Binding RgbDisplay, StringFormat='RGB = {0}'}"
FontSize="16"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</StackLayout>
</Frame>
</ContentView>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</RelativeLayout>
</ContentPage>
The padding in the outer frame seems to have interfered with the shape of your circle, rendering it into an elliptical figure. Removing the padding works and you can obtain a circular shape from your frame.
The corner radius property for a frame usually doesn't render for UWP application. So, you'll need to make a custom renderer for your frame to obtain the circle. As for your listview you can use the following code:
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ContentView Padding="5">
<RelativeLayout VerticalOptions="FillAndExpand">
<Frame OutlineColor="Accent" CornerRadius="6" HorizontalOptions="FillAndExpand" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width,Factor=1,Constant=0}" RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height,Factor=1,Constant=0}" >
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width,Factor=1,Constant=0}" RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height,Factor=1,Constant=0}" >
<Frame BackgroundColor="{Binding Color}" CornerRadius="60" RelativeLayout.HeightConstraint ="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.6, Constant=0}" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height,Factor=0.6,Constant=0}"/>
<StackLayout HorizontalOptions="FillAndExpand">
<Label Text="{Binding FriendlyName}" FontSize="22" VerticalOptions="StartAndExpand" />
<Label Text="{Binding RgbDisplay, StringFormat='RGB = {0}'}" FontSize="16" VerticalOptions = "CenterAndExpand" />
</StackLayout>
</StackLayout>
</Frame>
</RelativeLayout>
</ContentView>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
For frame, custom renderer for UWP:
public class CustomFrame:FrameRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Frame> e)
{
base.OnElementChanged(e);
if (Control != null)
{
var frame = e.NewElement;
Windows.UI.Color frameBG = Windows.UI.Color.FromArgb(
(byte)(frame.BackgroundColor.A * 255),
(byte)(frame.BackgroundColor.R * 255),
(byte)(frame.BackgroundColor.G * 255),
(byte)(frame.BackgroundColor.B * 255));
Control.CornerRadius = new Windows.UI.Xaml.CornerRadius(frame.CornerRadius);
Control.Background = new SolidColorBrush(frameBG);
frame.BackgroundColor = Xamarin.Forms.Color.Transparent;
}
}
}

Resources