I have a Xamarin portable project.
The Xaml pages I debug are totally blank and I cannot see any components on the pages on both Android and IOS.
How can I fix this?
Note: It gets no error messages, the pages are opening and I cannot see anything on them.
The problem occured after this error. When I fixed it the pages I debug become opening empty,
although they were working before InitializeComponent error.
Any help would be greatly appreciated.
This is my xaml :
<?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="AcikAkademi3.Layoutlar.GridOrnek3">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label BackgroundColor="Red" Text="0,0" Grid.Column="0" Grid.Row="0">
</Label>
<Label BackgroundColor="Blue" Text="1,0" Grid.Column="1" Grid.Row="0">
</Label>
<Label BackgroundColor="Yellow" Text="Açık Akademi" Grid.Column="2" Grid.Row="0"></Label>
<Label BackgroundColor="White" Text="0,1" Grid.Column="0" Grid.Row="1">
</Label>
<Label BackgroundColor="Silver" Text="1,1" Grid.Column="1" Grid.Row="1">
</Label>
<Label BackgroundColor="Lime" Text="2,1" Grid.Column="2" Grid.Row="1">
</Label>
</Grid>
</ContentPage>
This is my cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace AcikAkademi3.Layoutlar
{
public partial class GridOrnek3 : ContentPage
{
public GridOrnek3()
{
Padding = new Thickness(0, 20, 0, 0);
}
}
}
App.cs :
using AcikAkademi3.Layoutlar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
namespace AcikAkademi3
{
public class App : Application
{
public App()
{
MainPage = new GridOrnek3();
}
protected override void OnStart()
{
}
protected override void OnSleep()
{
}
protected override void OnResume()
{
}
}
}
You should call InitializeComponent() in ctor. Otherwise UI elements will not init from xaml file.
Okay, Looks like there is a mistake in xaml file
There is no Brown color, try to chose something from this table
This works for me
In fact, it seems that upon the InitializeComponent line is needed.