Xamarin Community Toolkit TabView badge does not work with ControlTemplate - xamarin.forms

I am using the Xamarin Community Toolkit TabView with a ControlTemplate in the TabViewItem, it works well. I tried adding a Badge to the TabViewItem and nothing happens. When I remove the ControlTemplate the Badge works perfectly. As a sanity test, I pulled the XCT sample code and tried adding a control template to a working TabView badge example and got the same results, no badge.
I am hoping that I am just missing something simple, but I have a feeling that the ControlTemplate and Badge are not compatible...
Does anyone have any examples of and XCT TabViewItem using a ControlTemplate and a badge?
Here is the sample xaml from the CustomTabsPage.xaml in the XCT Samples. I modified it by adding a Badge to the first tab, but it does not show the badge.
<pages:BasePage>
<pages:BasePage.Resources>
<ResourceDictionary>
<ControlTemplate
x:Key="TabItemTemplate">
<Grid
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image
Grid.Row="0"
VerticalOptions="Center"
HorizontalOptions="Center"
WidthRequest="24"
HeightRequest="24"
Margin="6"
Source="{TemplateBinding CurrentIcon}" />
<Label
Grid.Row="1"
HorizontalOptions="Center"
FontSize="{TemplateBinding FontSize}"
Text="Test"
TextColor="{TemplateBinding CurrentTextColor}" />
</Grid>
</ControlTemplate>
<ControlTemplate
x:Key="FabTabItemTemplate">
<Grid>
<ImageButton
InputTransparent="True"
Source="{TemplateBinding CurrentIcon}"
Padding="10"
HorizontalOptions="Center"
BackgroundColor="#FF0000"
HeightRequest="60"
WidthRequest="60"
Margin="6">
<ImageButton.CornerRadius>
<OnPlatform x:TypeArguments="x:Int32">
<On Platform="iOS" Value="30"/>
<On Platform="Android" Value="60"/>
<On Platform="UWP" Value="36"/>
</OnPlatform>
</ImageButton.CornerRadius>
<ImageButton.IsVisible>
<OnPlatform x:TypeArguments="x:Boolean">
<On Platform="Android, iOS, UWP">True</On>
<On Platform="macOS">False</On>
</OnPlatform>
</ImageButton.IsVisible>
</ImageButton>
<BoxView
InputTransparent="True"
HorizontalOptions="Center"
CornerRadius="30"
BackgroundColor="#FF0000"
HeightRequest="60"
WidthRequest="60"
Margin="6">
<BoxView.IsVisible>
<OnPlatform x:TypeArguments="x:Boolean">
<On Platform="Android, iOS, UWP">False</On>
<On Platform="macOS">True</On>
</OnPlatform>
</BoxView.IsVisible>
</BoxView>
</Grid>
</ControlTemplate>
<Style
x:Key="TabItemStyle"
TargetType="xct:TabViewItem">
<Setter
Property="FontSize"
Value="12" />
<Setter
Property="TextColor"
Value="#979797" />
<Setter
Property="TextColorSelected"
Value="#FF0000" />
</Style>
<Style
x:Key="CustomTabStyle"
TargetType="xct:TabView">
<Setter
Property="IsTabTransitionEnabled"
Value="True" />
<Setter
Property="TabStripHeight"
Value="48" />
<Setter
Property="TabContentBackgroundColor"
Value="#484848" />
<Setter
Property="TabStripPlacement"
Value="Bottom" />
</Style>
</ResourceDictionary>
</pages:BasePage.Resources>
<pages:BasePage.Content>
<Grid>
<xct:TabView
Style="{StaticResource CustomTabStyle}">
<xct:TabView.TabStripBackgroundView>
<BoxView
Color="#484848"
CornerRadius="36, 36, 0, 0"/>
</xct:TabView.TabStripBackgroundView>
<xct:TabViewItem
Text="Tab 1"
Icon="triangle.png"
ControlTemplate="{StaticResource TabItemTemplate}"
BadgeText="Test"
BadgeBackgroundColor="Pink"
BadgeBackgroundColorSelected="Red"
BadgeTextColor="White"
Style="{StaticResource TabItemStyle}">
<Grid
BackgroundColor="LawnGreen">
<Label
HorizontalOptions="Center"
VerticalOptions="Center"
Text="TabContent1" />
</Grid>
</xct:TabViewItem>
<xct:TabViewItem
Text="Tab 2"
Icon="circle.png"
ControlTemplate="{StaticResource FabTabItemTemplate}"
Style="{StaticResource TabItemStyle}"
TabTapped="OnFabTabTapped" />
<xct:TabViewItem
Text="Tab 3"
Icon="square.png"
ControlTemplate="{StaticResource TabItemTemplate}"
Style="{StaticResource TabItemStyle}">
<Grid
BackgroundColor="LightCoral">
<Label
HorizontalOptions="Center"
VerticalOptions="Center"
Text="TabContent3" />
</Grid>
</xct:TabViewItem>
</xct:TabView>
</Grid>
</pages:BasePage.Content>
</pages:BasePage>

You could add a BageView in your ControlTemplate like below and then remove the Badge properties in TabViewItem.
Also please slightly adjust the position of the badge where you want to place it.
<ControlTemplate
x:Key="TabItemTemplate">
<Grid
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image
Grid.Row="0"
VerticalOptions="Center"
HorizontalOptions="Center"
WidthRequest="24"
HeightRequest="24"
Margin="6"
Source="{TemplateBinding CurrentIcon}" />
<Label
Grid.Row="1"
HorizontalOptions="Center"
FontSize="{TemplateBinding FontSize}"
Text="Test"
TextColor="{TemplateBinding CurrentTextColor}" />
<xct:BadgeView
Grid.Row="0" Grid.Column="1"
BackgroundColor="Pink"
TextColor="White"
Text="123"
/>
</Grid>
</ControlTemplate>
Reference link:
https://learn.microsoft.com/en-us/xamarin/community-toolkit/views/badgeview

Related

scrollview doesn't scroll up enough to see the rest of views xamarin.forms

i wrote this code for a registration page. in some phones, the screen doesn't fit for all the views so i used a scrollview so that the user could scroll down through them. the problem i'm facing is that the scrollview doesn't scroll enough upwards. the button at the end doesn't appear. here is my xaml code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ALNahrainAlphaApp.RegisterPage"
xmlns:controls="clr-namespace:ALNahrainAlphaApp;assembly=ALNahrainAlphaApp"
>
<ContentPage.Content>
<ScrollView Orientation="Vertical">
<ScrollView.Background>
<LinearGradientBrush EndPoint="0,1">
<GradientStop Color="#0d98ba"
Offset="0.2" />
<GradientStop Color="White"
Offset="1" />
</LinearGradientBrush>
</ScrollView.Background>
<StackLayout>
<Grid>
<StackLayout>
<Frame CornerRadius="50" BorderColor="White" BackgroundColor="Transparent" Margin="20,50">
<Grid Padding="1" ColumnSpacing="1" RowSpacing="0" Margin="0,160">
<Grid.RowDefinitions>
<RowDefinition Height="70" />
<RowDefinition Height="70" />
<RowDefinition Height="70" />
<RowDefinition Height="70" />
<RowDefinition Height="70" />
<RowDefinition Height="70" />
<RowDefinition Height="70" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
</Grid.ColumnDefinitions>
<Frame CornerRadius="20" Margin="0,5" />
<controls:CustomEntry
Grid.Row="0"
x:Name="id"
HorizontalOptions="FillAndExpand"
Margin="10,5"
TextColor="Black"
Placeholder="ID"
FontSize="16"
PlaceholderColor="Gray"
/>
<Frame CornerRadius="20" Grid.Row="1" Margin="0,5"/>
<controls:CustomEntry
Grid.Row="1"
x:Name="firstname"
HorizontalOptions="Fill"
Margin="10,5"
TextColor="Black"
FontSize="16"
Placeholder="First Name"
PlaceholderColor="Gray"
/>
<Frame CornerRadius="20" Grid.Row="2" Margin="0,5"/>
<controls:CustomEntry
Grid.Row="2"
x:Name="lastname"
HorizontalOptions="Fill"
Margin="10,5"
TextColor="Black"
Placeholder="Last Name"
PlaceholderColor="Gray"
FontSize="16"
/>
<Frame CornerRadius="20" Grid.Row="3" Margin="0,5"/>
<controls:CustomEntry
FontSize="16"
Grid.Row="3"
x:Name="role"
HorizontalOptions="Fill"
Margin="10,5"
TextColor="Black"
Placeholder="Role"
PlaceholderColor="Gray"
/>
<Frame CornerRadius="20" Grid.Row="4" Margin="0,5"/>
<controls:CustomEntry
FontSize="16"
Grid.Row="4"
x:Name="user_name"
HorizontalOptions="Fill"
Margin="10,5"
TextColor="Black"
Placeholder="Username"
PlaceholderColor="Gray"
/>
<Frame CornerRadius="20" Grid.Row="5" Margin="0,5"/>
<controls:CustomEntry
FontSize="16"
Grid.Row="5"
x:Name="password"
HorizontalOptions="Fill"
Margin="10,5"
TextColor="Black"
Placeholder="Password"
PlaceholderColor="Gray"
/>
<StackLayout Orientation="Horizontal" Grid.Row="6">
<Label Text="Allow Access" TextColor="Black" FontSize="16" HorizontalOptions="Center" VerticalOptions="Center" Margin="15,5"/>
<Switch
ThumbColor="Black"
OnColor="White"
x:Name="appaccess"
HorizontalOptions="Center"
VerticalOptions="Center"
Margin="40,0"
/>
</StackLayout>
</Grid>
</Frame>
<Button CornerRadius="50" Text="Submit" FontSize="Medium" BackgroundColor="White" TextColor="Black" FontFamily="audiofont" x:Name="save" HeightRequest="60" WidthRequest="140" HorizontalOptions="Center" VerticalOptions="Center" Margin="0,-85" Clicked="save_Clicked"/>
</StackLayout>
<Frame CornerRadius="50" HeightRequest="100" WidthRequest="100" HorizontalOptions="Center" VerticalOptions="Start" Padding="-2" BorderColor="White" Margin="20,5,20,0">
<Image HeightRequest="150" WidthRequest="150" x:Name="userprofile" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"/>
</Frame>
</Grid>
</StackLayout>
</ScrollView>
</ContentPage.Content>
</ContentPage>
i tried different things, i put the scrollview inside a contentview but i didn't work. what am i doing wrong?
You can try to add property RowDefinitions and define two row for the outer grid.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<!--other code-->
<Grid>
You can refer to the following code:
<ContentPage.Content>
<ScrollView Orientation="Vertical">
<ScrollView.Background>
<LinearGradientBrush EndPoint="0,1">
<GradientStop Color="#0d98ba"
Offset="0.2" />
<GradientStop Color="White"
Offset="1" />
</LinearGradientBrush>
</ScrollView.Background>
<StackLayout>
<Grid>
<!--add two row here-->
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<StackLayout>
<Frame CornerRadius="50" BorderColor="White" BackgroundColor="Transparent" Margin="20,50">
<Grid Padding="1" ColumnSpacing="1" RowSpacing="0" Margin="0,160">
<Grid.RowDefinitions>
<RowDefinition Height="70" />
<RowDefinition Height="70" />
<RowDefinition Height="70" />
<RowDefinition Height="70" />
<RowDefinition Height="70" />
<RowDefinition Height="70" />
<RowDefinition Height="70" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*" />
</Grid.ColumnDefinitions>
<Frame CornerRadius="20" Margin="0,5" />
<Entry
Grid.Row="0"
x:Name="id"
HorizontalOptions="FillAndExpand"
Margin="10,5"
TextColor="Black"
Placeholder="ID"
FontSize="16"
PlaceholderColor="Gray"
/>
<Frame CornerRadius="20" Grid.Row="1" Margin="0,5"/>
<Entry
Grid.Row="1"
x:Name="firstname"
HorizontalOptions="Fill"
Margin="10,5"
TextColor="Black"
FontSize="16"
Placeholder="First Name"
PlaceholderColor="Gray"
/>
<Frame CornerRadius="20" Grid.Row="2" Margin="0,5"/>
<Entry
Grid.Row="2"
x:Name="lastname"
HorizontalOptions="Fill"
Margin="10,5"
TextColor="Black"
Placeholder="Last Name"
PlaceholderColor="Gray"
FontSize="16"
/>
<Frame CornerRadius="20" Grid.Row="3" Margin="0,5"/>
<Entry
FontSize="16"
Grid.Row="3"
x:Name="role"
HorizontalOptions="Fill"
Margin="10,5"
TextColor="Black"
Placeholder="Role"
PlaceholderColor="Gray"
/>
<Frame CornerRadius="20" Grid.Row="4" Margin="0,5"/>
<Entry
FontSize="16"
Grid.Row="4"
x:Name="user_name"
HorizontalOptions="Fill"
Margin="10,5"
TextColor="Black"
Placeholder="Username"
PlaceholderColor="Gray"
/>
<Frame CornerRadius="20" Grid.Row="5" Margin="0,5"/>
<Entry
FontSize="16"
Grid.Row="5"
x:Name="password"
HorizontalOptions="Fill"
Margin="10,5"
TextColor="Black"
Placeholder="Password"
PlaceholderColor="Gray"
/>
<StackLayout Orientation="Horizontal" Grid.Row="6">
<Label Text="Allow Access" TextColor="Black" FontSize="16" HorizontalOptions="Center" VerticalOptions="Center" Margin="15,5"/>
<Switch
ThumbColor="Black"
OnColor="White"
x:Name="appaccess"
HorizontalOptions="Center"
VerticalOptions="Center"
Margin="40,0"
/>
</StackLayout>
</Grid>
</Frame>
<Button CornerRadius="50" Text="Submit" FontSize="Medium" BackgroundColor="White" TextColor="Black" FontFamily="audiofont" x:Name="save" HeightRequest="60" WidthRequest="140" HorizontalOptions="Center" Margin="0,-85" />
</StackLayout>
<Frame CornerRadius="50" HeightRequest="100" WidthRequest="100" HorizontalOptions="Center" VerticalOptions="Start" Padding="-2" BorderColor="White" Margin="20,5,20,0">
<Image HeightRequest="150" WidthRequest="150" x:Name="userprofile" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Source="grass.png"/>
</Frame>
</Grid>
</StackLayout>
</ScrollView>
</ContentPage.Content>
Change the Margin
<Frame CornerRadius="50" BorderColor="White" BackgroundColor="Transparent" Margin="20,50">
<Grid Padding="1" ColumnSpacing="1" RowSpacing="0" Margin="0,90">

Collection view selected item color is set as Gray not Transparent in Xamarin iOS

I am using the latest xamarin forms version because in the previous version I am facing the issue in the collection view when I selected the item the selected item color set as gray if I set the background as Transparent. I upgraded the new version ( https://github.com/xamarin/Xamarin.Forms/pull/14672 they mentioned it was fixed in the latest version) but I am getting the same issue in the latest version also.
<ContentPage.Resources>
<Style TargetType="Grid">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor"
Value="Transparent" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
</ContentPage.Resources>
<StackLayout Margin="20">
<CollectionView ItemsSource="{Binding Monkeys}"
SelectionMode="Single" >
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Grid.RowSpan="2"
Source="{Binding ImageUrl}"
Aspect="AspectFill"
HeightRequest="60"
WidthRequest="60" />
<Label Grid.Column="1"
Text="{Binding Name}"
FontAttributes="Bold" />
<Label Grid.Row="1"
Grid.Column="1"
Text="{Binding Location}"
FontAttributes="Italic"
VerticalOptions="End" />
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
Anyone please suggest any workaround for this. My requirement is to set the background as Transparent for selected Item in xamarin iOS

BottomBar with customizations

I wish I could create a BottomBar that would allow me to have a graphic like this, with a button bigger than all the others. I tried with a TabbedPage but it doesn't allow me this customization. I tried with a TabView but it doesn't allow me to insert ContentPage pages by pressing buttons. I would like a BottomBar that would allow me to have this graphic and to be able to use pages as button content.
Example
You could use TabView With Action Button from the Xamarin Community Toolkit linked below. By not assigning any content and instead assigning an event to the TabTapped property, you will display a button instead of another tab.
Install from NuGet: https://www.nuget.org/packages/Xamarin.CommunityToolkit/
Add xct:
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
Xaml:
<ContentPage.Resources>
<ResourceDictionary>
<ControlTemplate
x:Key="TabItemTemplate">
<Grid
RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Image
Grid.Row="0"
VerticalOptions="Center"
HorizontalOptions="Center"
WidthRequest="24"
HeightRequest="24"
Margin="6"
Source="{TemplateBinding CurrentIcon}" />
<Label
Grid.Row="1"
HorizontalOptions="Center"
FontSize="{TemplateBinding FontSize}"
Text="{TemplateBinding Text}"
TextColor="{TemplateBinding CurrentTextColor}" />
</Grid>
</ControlTemplate>
<ControlTemplate
x:Key="FabTabItemTemplate">
<Grid>
<ImageButton
InputTransparent="True"
Source="circle.png"
Padding="10"
HorizontalOptions="Center"
BackgroundColor="#FF0000"
HeightRequest="60"
WidthRequest="60"
Margin="6">
<ImageButton.CornerRadius>
<OnPlatform x:TypeArguments="x:Int32">
<On Platform="iOS" Value="30"/>
<On Platform="Android" Value="60"/>
<On Platform="UWP" Value="36"/>
</OnPlatform>
</ImageButton.CornerRadius>
<ImageButton.IsVisible>
<OnPlatform x:TypeArguments="x:Boolean">
<On Platform="Android, iOS, UWP">True</On>
<On Platform="macOS">False</On>
</OnPlatform>
</ImageButton.IsVisible>
</ImageButton>
<BoxView
InputTransparent="True"
HorizontalOptions="Center"
CornerRadius="30"
BackgroundColor="#FF0000"
HeightRequest="60"
WidthRequest="60"
Margin="6">
<BoxView.IsVisible>
<OnPlatform x:TypeArguments="x:Boolean">
<On Platform="Android, iOS, UWP">False</On>
<On Platform="macOS">True</On>
</OnPlatform>
</BoxView.IsVisible>
</BoxView>
</Grid>
</ControlTemplate>
<Style
x:Key="TabItemStyle"
TargetType="xct:TabViewItem">
<Setter
Property="FontSize"
Value="12" />
<Setter
Property="TextColor"
Value="#979797" />
<Setter
Property="TextColorSelected"
Value="#FF0000" />
</Style>
<Style
x:Key="CustomTabStyle"
TargetType="xct:TabView">
<Setter
Property="IsTabTransitionEnabled"
Value="True" />
<Setter
Property="TabStripHeight"
Value="48" />
<Setter
Property="TabContentBackgroundColor"
Value="#484848" />
<Setter
Property="TabStripPlacement"
Value="Bottom" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<Grid>
<xct:TabView
Style="{StaticResource CustomTabStyle}">
<xct:TabView.TabStripBackgroundView>
<BoxView
Color="#484848"
CornerRadius="36, 36, 0, 0"/>
</xct:TabView.TabStripBackgroundView>
<xct:TabViewItem
Text="Tab 1"
Icon="triangle.png"
ControlTemplate="{StaticResource TabItemTemplate}"
Style="{StaticResource TabItemStyle}">
<Grid
BackgroundColor="LawnGreen">
<Label
HorizontalOptions="Center"
VerticalOptions="Center"
Text="TabContent1" />
</Grid>
</xct:TabViewItem>
<xct:TabViewItem
Text="Tab 2"
Icon="circle.png"
ControlTemplate="{StaticResource FabTabItemTemplate}"
Style="{StaticResource TabItemStyle}"
TabTapped="OnFabTabTapped" />
<xct:TabViewItem
Text="Tab 3"
Icon="square.png"
ControlTemplate="{StaticResource TabItemTemplate}"
Style="{StaticResource TabItemStyle}">
<Grid
BackgroundColor="LightCoral">
<Label
HorizontalOptions="Center"
VerticalOptions="Center"
Text="TabContent3" />
</Grid>
</xct:TabViewItem>
</xct:TabView>
</Grid>
Update:
Do I have the possibility to insert a ContentPage by pressing on in TabViewItem and keep the TabVIew
You could set the page as contentview.
<?xml version="1.0" encoding="utf-8" ?>
<ContentView
x:Class="App9.Page1"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">
<ContentView.Content>
<StackLayout>
<Label
HorizontalOptions="CenterAndExpand"
Text="Welcome to Page1!"
VerticalOptions="CenterAndExpand" />
</StackLayout>
</ContentView.Content>
</ContentView>
public partial class Page1 : ContentView
{
public Page1()
{
InitializeComponent();
}
}
And then load in the TabViewItem.
<xct:TabViewItem
ControlTemplate="{StaticResource TabItemTemplate}"
Icon="square.png"
Style="{StaticResource TabItemStyle}"
Text="Tab 3">
<!--<Grid
BackgroundColor="LightCoral">
<Label
HorizontalOptions="Center"
VerticalOptions="Center"
Text="TabContent3" />
</Grid>-->
<local:Page1 />
</xct:TabViewItem>

Xamarin Forms UWP page looks blank on local machine but works on Windows 10 phone

I have an app created with the latest Xamarin.Forms 2.3 and tested it with a Lumia 550 Phone.
The page contains some custom Entry, a DatePicker and a Button.
The app on the phone works perfectly but on the local machine, I only get a blank screen (only with this page).
Phone:
Local machine (upgraded with Creators Update):
A few months ago, they both worked with Xamarin.Forms 2.2.
UPDATE:
Here is the XAML code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentView x:Class="MyProject.Views.UserDataView"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:cm="clr-namespace:Caliburn.Micro.Xamarin.Forms;assembly=Caliburn.Micro.Platform.Xamarin.Forms"
xmlns:controls="clr-namespace:XLabs.Forms.Controls;assembly=XLabs.Forms"
xmlns:component="clr-namespace:MyBaseProject.Component;assembly=MyBaseProject"
xmlns:converter="clr-namespace:MyBaseProject.Converter;assembly=MyBaseProject"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Padding="0">
<ContentView.Resources>
<ResourceDictionary>
<converter:BoolConverter x:Key="boolConverter" />
</ResourceDictionary>
</ContentView.Resources>
<ScrollView>
<Grid Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Grid.Row="0"
Style="{DynamicResource BoldField}"
Text="Input1:" />
<component:CustomEntry Grid.Row="1"
Keyboard="Text"
MaxLength="100"
Text="{Binding Param1.Value1}" />
<Label Grid.Row="2" Text="Input2:" />
<DatePicker Grid.Row="3"
Date="{Binding Param1.Value2}"
Format="yyyy.MM.dd"
VerticalOptions="CenterAndExpand" />
<StackLayout Grid.Row="4" Orientation="Horizontal">
<Label x:Name="lblCF"
Style="{DynamicResource BoldField}"
Text="Input3:" />
<Label FontAttributes="Italic"
IsVisible="{Binding Source={x:Reference cfEntry}, Path=IsOK,Converter={StaticResource boolConverter}}}"
Text="(invalid)" />
</StackLayout>
<component:CustomSNEntry x:Name="cfEntry"
Grid.Row="5"
MaxLength="11"
Text="{Binding Param1.Value3}}" />
<Label Grid.Row="6" Text="Input4:" />
<component:CustomEntry Grid.Row="7"
Keyboard="Text"
MaxLength="70"
Text="{Binding Param1.Value4}}" />
<Label Grid.Row="8" Text="Input5:" />
<component:CustomEntry Grid.Row="9"
Keyboard="Text"
MaxLength="70"
Text="{Binding Param1.Value5}" />
<Label Grid.Row="10" Text="Input6:" />
<component:CustomEntry Grid.Row="11"
Keyboard="Text"
MaxLength="10"
Text="{Binding Param1.Value6}" />
<Label Grid.Row="12" Text="Input7:" />
<component:CustomEntry Grid.Row="13"
Keyboard="Text"
MaxLength="100"
Text="{Binding Param1.Value7}" />
<Label Grid.Row="14" Text="Input8:" />
<component:CustomEntry Grid.Row="15"
Keyboard="Telephone"
MaxLength="15"
Text="{Binding Param1.Value8}" />
<Button Grid.Row="16"
cm:Message.Attach="Save"
Style="{DynamicResource BasicButton}"
Text="Save" />
</Grid>
</ScrollView>
</ContentView>
The custom components (CustomEntry and CustomSNEntry) are descendants of the Entry class with a Behavior added to them.
What should I do about this?
UPDATE 2:
The issue still persists and it looks like the following default style causes the problem:
<Style ApplyToDerivedTypes="True" TargetType="components:MyEntry">
<Setter Property="FontSize">
<Setter.Value>
<OnIdiom x:TypeArguments="x:Double"
Phone="18"
Tablet="28" />
</Setter.Value>
</Setter>
<Setter Property="HeightRequest">
<Setter.Value>
<OnIdiom x:TypeArguments="x:Double"
Phone="40"
Tablet="50" />
</Setter.Value>
</Setter>
</Style>
I don't know why.
If I remove the Height setter and leave the FontSize, it shows nothing.
If I remove the FontSize setter and leave the Height, it shows only the labels.
If I remove both of them, it shows everything normal.

My <ContentPage.Content> in Xamarin.Forms is not showing up?

When I add toolbar in my Main Page the content page disappear. What should I do to fix this? Can you share insight or point me to links for me to learn. I am just starting with xamarin forms. I been finding the answer the whole day but I can't find one.
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:KLConnect"
x:Class="KLConnect.MainPage"
Title="KLConnect TTM+ Operation">
<Label x:Name="label"
FontSize="Medium"
VerticalOptions="Center"
HorizontalOptions="Center" />
<ContentPage.ToolbarItems>
<ToolbarItem Text="setting"
Order="Primary"
Clicked="OnToolbarItemClicked">
<ToolbarItem.Icon>
<OnPlatform x:TypeArguments="FileImageSource"
Android="ic_build_white_48dp.png"/>
</ToolbarItem.Icon>
</ToolbarItem>
<ToolbarItem Text="close"
Order="Primary"
Clicked="OnToolbarItemClicked">
<ToolbarItem.Icon>
<OnPlatform x:TypeArguments="FileImageSource"
Android="ic_highlight_off_white_48dp.png"/>
</ToolbarItem.Icon>
</ToolbarItem>
<ToolbarItem Text="help"
Order="Primary"
Clicked="OnToolbarItemClicked">
<ToolbarItem.Icon>
<OnPlatform x:TypeArguments="FileImageSource"
Android="ic_help_outline_white_48dp.png"/>
</ToolbarItem.Icon>
</ToolbarItem>
</ContentPage.ToolbarItems>
<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="plainButton" TargetType="Button">
<Setter Property="BackgroundColor" Value="#eee"/>
<Setter Property="TextColor" Value="Black" />
<Setter Property="BorderRadius" Value="0"/>
<Setter Property="FontSize" Value="40" />
</Style>
<Style x:Key="darkerButton" TargetType="Button">
<Setter Property="BackgroundColor" Value="#ddd"/>
<Setter Property="TextColor" Value="Black" />
<Setter Property="BorderRadius" Value="0"/>
<Setter Property="FontSize" Value="40" />
</Style>
<Style x:Key="orangeButton" TargetType="Button">
<Setter Property="BackgroundColor" Value="#E8AD00"/>
<Setter Property="TextColor" Value="White" />
<Setter Property="BorderRadius" Value="0"/>
<Setter Property="FontSize" Value="40" />
</Style>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<Grid x:Name="controlGrid" RowSpacing="1" ColumnSpacing="1">
<Grid.RowDefinitions>
<RowDefinition Height="150" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Text="0" Grid.Row="0" HorizontalTextAlignment="End" VerticalTextAlignment="End" TextColor="White"
FontSize="60" Grid.ColumnSpan="4" />
<Button Text = "C" Grid.Row="1" Grid.Column="0"
Style="{StaticResource darkerButton}" />
<Button Text = "+/-" Grid.Row="1" Grid.Column="1"
Style="{StaticResource darkerButton}" />
<Button Text = "%" Grid.Row="1" Grid.Column="2"
Style="{StaticResource darkerButton}" />
<Button Text = "div" Grid.Row="1" Grid.Column="3"
Style="{StaticResource orangeButton}" />
<Button Text = "7" Grid.Row="2" Grid.Column="0"
Style="{StaticResource plainButton}" />
<Button Text = "8" Grid.Row="2" Grid.Column="1"
Style="{StaticResource plainButton}" />
<Button Text = "9" Grid.Row="2" Grid.Column="2"
Style="{StaticResource plainButton}" />
<Button Text = "X" Grid.Row="2" Grid.Column="3"
Style="{StaticResource orangeButton}" />
<Button Text = "4" Grid.Row="3" Grid.Column="0"
Style="{StaticResource plainButton}" />
<Button Text = "5" Grid.Row="3" Grid.Column="1"
Style="{StaticResource plainButton}" />
<Button Text = "6" Grid.Row="3" Grid.Column="2"
Style="{StaticResource plainButton}" />
<Button Text = "-" Grid.Row="3" Grid.Column="3"
Style="{StaticResource orangeButton}" />
<Button Text = "1" Grid.Row="4" Grid.Column="0"
Style="{StaticResource plainButton}" />
<Button Text = "2" Grid.Row="4" Grid.Column="1"
Style="{StaticResource plainButton}" />
<Button Text = "3" Grid.Row="4" Grid.Column="2"
Style="{StaticResource plainButton}" />
<Button Text = "+" Grid.Row="4" Grid.Column="3"
Style="{StaticResource orangeButton}" />
<Button Text = "0" Grid.ColumnSpan="2"
Grid.Row="5" Grid.Column="0" Style="{StaticResource plainButton}" />
<Button Text = "." Grid.Row="5" Grid.Column="2"
Style="{StaticResource plainButton}" />
<Button Text = "=" Grid.Row="5" Grid.Column="3"
Style="{StaticResource orangeButton}" />
</Grid>
</ContentPage.Content>
</ContentPage>
It's because you have a Label already set at the beginning of your xaml.
Remove this
<Label x:Name="label"
FontSize="Medium"
VerticalOptions="Center"
HorizontalOptions="Center" />

Resources