0

J'ai un projet portable Xamarin.
Les pages Xaml que je débogue sont totalement vides et je ne vois aucun composant sur les pages d'Android et d'IOS.
Ecran vide sur Xamarin

Comment puis-je résoudre ce problème?

Remarque: Il ne reçoit aucun message d'erreur, les pages s'ouvrent et je ne vois rien sur eux.
Le problème est survenu après this error. Lorsque je l'ai corrigé, les pages que je déboguais devenaient vides,
même si elles fonctionnaient avant l'erreur InitializeComponent.

Toute aide serait grandement appréciée.

Ceci est mon 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> 

Ceci est mon 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() 
     { 
     } 
    } 
} 
+0

Pourquoi voter en baisse? –

+1

Vous ne postez aucun code d'échantillon, aucun message d'erreur et ne montrez aucun effort de votre part. Nous n'avons aucun miroir magique dans lequel nous pouvons voir tout ce que vous faites, donc une enquête et des informations de votre part sont non seulement appréciées, mais aussi nécessaires si vous voulez de bonnes réponses. –

+0

Okey J'ai mis à jour ma question. –

Répondre

2

Vous devez appeler InitializeComponent() en cteur. Sinon, les éléments de l'interface utilisateur ne seront pas init à partir du fichier xaml.

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() 
     { 
      InitializeComponent(); 
      Padding = new Thickness(0, 20, 0, 0); 
     } 
    } 
} 

Ok, On dirait qu'il ya une erreur dans le fichier XAML

<Label BackgroundColor="Brown" Text="0,1" Grid.Column="0" Grid.Row="1"> 
    </Label> 

Il n'y a pas de couleur Brown, essayez de choisir quelque chose de this table

Cela fonctionne pour moi

<Grid> 
    <Grid.RowDefinitions> 
    <RowDefinition Height="*"/> 
    <RowDefinition Height="*"/> 
    </Grid.RowDefinitions> 

    <Grid.ColumnDefinitions> 
    <ColumnDefinition Width="*"/> 
    <ColumnDefinition Width="*"/> 
    <ColumnDefinition Width="Auto"/> 
    </Grid.ColumnDefinitions> 

    <Label Grid.Column="0" 
      Grid.Row="0" 
      BackgroundColor="Red" 
      Text="0,0" /> 

    <Label Grid.Column="1" 
      Grid.Row="0" 
      BackgroundColor="Blue" 
      Text="1,0" /> 

    <Label Grid.Column="2" 
      Grid.Row="0" 
      BackgroundColor="Yellow" 
      Text="Açık Akademi"/> 

    <Label Grid.Column="0" 
      Grid.Row="1" 
      BackgroundColor="Olive" 
      Text="0,1" /> 

    <Label Grid.Column="1" 
      Grid.Row="1" 
      BackgroundColor="Silver" 
      Text="1,1" /> 

    <Label Grid.Column="2" 
      Grid.Row="1" 
      BackgroundColor="Lime" 
      Text="2,1" /> 

</Grid> 
+0

Okey ont ajouté mais il obtient toujours un écran vide. –

+0

Pourriez-vous s'il vous plaît montrer votre App.cs et App.xaml –

+0

Okey mis à jour et ajouté App.cs –

0

En fait, il semble que sur le InitializeCo Une ligne supplémentaire est nécessaire.