Hello,
I'ved read the documentation today at xamarin-doc and i'ved juste adapt one or more elements. But I have a problem, the text is not visible. The list exist, and she have 2 line (I can click on it), but the text property is empty.
MainPageCS
using System; using Xamarin.Forms; namespace GestionnairesCopro.Master.SignIn { public class MainPageCS : MasterDetailPage { MasterPageCS masterPage; public MainPageCS() { masterPage = new MasterPageCS(); Master = masterPage; Detail = new NavigationPage(new SignInPage()); masterPage.ListView.ItemSelected += OnItemSelected; } void OnItemSelected(object sender, SelectedItemChangedEventArgs e) { var item = e.SelectedItem as MasterPageItem; if (item != null) { Detail = new NavigationPage((Page)Activator.CreateInstance(item.TargetType)); masterPage.ListView.SelectedItem = null; IsPresented = false; } } } }
MasterPageCS
using System.Collections.Generic; using Xamarin.Forms; namespace GestionnairesCopro.Master.SignIn { public class MasterPageCS : ContentPage { public ListView ListView { get { return listView; } } ListView listView; public MasterPageCS() { var masterPageItems = new List<MasterPageItem>(); masterPageItems.Add(new MasterPageItem { Title = "Connexion", TargetType = typeof(SignInPage) }); masterPageItems.Add(new MasterPageItem { Title = "ParamËtres", TargetType = typeof(SettingsPage) }); listView = new ListView { ItemsSource = masterPageItems, ItemTemplate = new DataTemplate(() => { var textCell = new TextCell(); textCell.SetBinding(TextCell.TextProperty, "Title"); return textCell; }), VerticalOptions = LayoutOptions.FillAndExpand, SeparatorVisibility = SeparatorVisibility.None }; Padding = new Thickness(0, 40, 0, 0); Icon = "hamburger.png"; Title = "Personal Organiser"; Content = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, Children = { listView } }; } } }
MasterPageItem
using System; namespace GestionnairesCopro.Master.SignIn { class MasterPageItem { public string Title; public Type TargetType; } }
Sorry for my bad english.
Thanks for your help.
I'ved solved my problem. Master item need to specifying get and set.
using System; namespace GestionnairesCopro.Master { [Xamarin.Forms.Internals.Preserve(AllMembers = true)] public class MasterPageItem { public string Title { get; set; } public Type targetType { get; set; } } }
Thanks for your help
Answers
Up. Please, need help.
Hi,
i think i've faced this issue already once. The text is not empty, it's just the color of the TextCells that is probably inheriting from the background color of the MasterPage so you can't read anything.
Try to set the TextColor property of TextCell items inside the listview, something like this (assuming MasterPage Background color is black):
Hope it helps.
Thanks for your help but it's not that
I don't understand.
I'ved solved my problem. Master item need to specifying get and set.
Thanks for your help