Этот снимок экрана является результатом UWP как Startup Project. Это именно то, что я хочу.
! https://1drv.ms/u/s!An07nml8jWWSwbUM-Y5E7IFVZYlb1A
Этот скриншот является результатом Android как Startup Project. Это не то, что я хочу. Метки не отображают текст полностью, они не отображают все поля, и появляется только одно изображение, которое не является правильным.
! https://1drv.ms/u/s!An07nml8jWWSwbUOmo4tPelZlxknYA
Почему такие радикальные различия между двумя проектами? Я знаю, что есть некоторые незначительные различия, но это слишком много и не может быть использовано. С чего начать, как заставить работать версию для Android?
using OFam.ViewModels;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace OFam.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainView : ContentPage
{
public ObservableCollection<Models.TreeBranches> branches { get; set; }
public MainView()
{
InitializeComponent();
branches = new ObservableCollection<Models.TreeBranches>();
ListView viewList = new ListView();
this.Title = "Family Tree";
viewList.ItemTemplate = new DataTemplate(typeof(CustomTreeBranches));
branches.Add(new Models.TreeBranches {
BranchNumber = 1,
FullName = "Garland Don Osborne",
Birthday ="1/22/1922",
Father = "Dick Osborn",
Mother = "Hazel Hinton",
Spouse1 = "Iola May Hayes",
Spouse2 = "",
Spouse3 = "",
Child1 = "John Richard Osborne",
Child2 = "Donna May Osborne",
Child3 = "Garland Darrell Osborne",
Child4 = "Orval Ray Osborne",
Residence = "Oakdale, California",
Image = "Photos/GarlandDonOsborne.jpg" });
branches.Add(new Models.TreeBranches {
BranchNumber = 2,
FullName = "Iola May Hayes",
Birthday ="11/31/1920",
Father = "Raymond Hayes",
Mother = "Gracie Postoak",
Spouse1 = "Garland Don Osborne",
Spouse2 = "",
Spouse3 = "",
Child1 = "John Richard Osborne",
Child2 = "Donna May Osborne",
Child3 = "Garland Darrell Osborne",
Child4 = "Orval Ray Osborne",
Residence = "Highlands Ranch, Colorado",
Image = "Photos/IolaMayHayes.jpg" });
public class CustomTreeBranches : ViewCell
{
public CustomTreeBranches()
{
var img = new Image();
var bdLabel = new Label();
var nameLabel = new Label();
var bnLabel = new Label();
var frLabel = new Label();
var mrLabel = new Label();
var c1Label = new Label();
var c2Label = new Label();
var c3Label = new Label();
var c4Label = new Label();
var s1Label = new Label();
var s2Label = new Label();
var s3Label = new Label();
var rdLabel = new Label();
var sp1Label = new Label()
{
Text = "Father and Mother",
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Start
};
var sp2Label = new Label()
{
Text = "Children",
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Start
};
var sp3Label = new Label()
{
Text = "Spouse(s)",
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center
};
var sp4Label = new Label()
{
Text = "Latest Residence",
FontAttributes = FontAttributes.Bold,
HorizontalOptions = LayoutOptions.Center
};
var vLayout = new StackLayout();
var hLayout = new StackLayout() { BackgroundColor = Color.LavenderBlush };
img.SetBinding(Image.SourceProperty, new Binding("Image"));
bdLabel.SetBinding(Label.TextProperty, new Binding("Birthday"));
nameLabel.SetBinding(Label.TextProperty, new Binding("FullName"));
frLabel.SetBinding(Label.TextProperty, new Binding("Father"));
mrLabel.SetBinding(Label.TextProperty, new Binding("Mother"));
c1Label.SetBinding(Label.TextProperty, new Binding("Child1"));
c2Label.SetBinding(Label.TextProperty, new Binding("Child2"));
c3Label.SetBinding(Label.TextProperty, new Binding("Child3"));
c4Label.SetBinding(Label.TextProperty, new Binding("Child4"));
s1Label.SetBinding(Label.TextProperty, new Binding("Spouse1"));
s2Label.SetBinding(Label.TextProperty, new Binding("Spouse2"));
s3Label.SetBinding(Label.TextProperty, new Binding("Spouse3"));
rdLabel.SetBinding(Label.TextProperty, new Binding("Residence"));
hLayout.Orientation = StackOrientation.Horizontal;
hLayout.HorizontalOptions = LayoutOptions.Fill;
img.HorizontalOptions = LayoutOptions.End;
img.WidthRequest = 250;
img.HeightRequest = 250;
nameLabel.FontSize = 18;
vLayout.HorizontalOptions = LayoutOptions.Start;
vLayout.Children.Add(nameLabel);
vLayout.Children.Add(bdLabel);
vLayout.Children.Add(sp1Label);
vLayout.Children.Add(frLabel);
vLayout.Children.Add(mrLabel);
vLayout.Children.Add(sp2Label);
vLayout.Children.Add(c1Label);
vLayout.Children.Add(c2Label);
vLayout.Children.Add(c3Label);
vLayout.Children.Add(c4Label);
vLayout.Children.Add(sp3Label);
vLayout.Children.Add(s1Label);
vLayout.Children.Add(s2Label);
vLayout.Children.Add(s3Label);
vLayout.Children.Add(sp4Label);
vLayout.Children.Add(rdLabel);
hLayout.Children.Add(vLayout);
hLayout.Children.Add(img);
View = hLayout;
}
}
}
}