Esempio n. 1
0
        public ListViewEx()
        {
            var classNames = new[]
            {
                "Building Cross Platform Apps with Xamarin Part1",
                "Building Cross Platform Apps with Xamarin Part2",
                "Building Cross Platform Apps with Xamarin Part3"
            };

            //TODO: Translate into XAML
            Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);
            var listView = new ListView();
            //listView.ItemsSource = classNames;
            listView.ItemsSource = PluralsightCourse.GetCourseList();

            var cell = new DataTemplate(typeof(TextCell));
            //cell.SetBinding(TextCell.TextProperty, new Binding("."));
            cell.SetBinding(TextCell.TextProperty, new Binding("Title"));
            cell.SetBinding(TextCell.DetailProperty, new Binding("Author"));
            cell.SetValue(TextCell.TextColorProperty, Color.Red);
            cell.SetValue(TextCell.DetailColorProperty,Color.Yellow);

            listView.ItemTemplate = cell;
            Content = listView;
        }
        public void Init()
        {
            if (Device.OS == TargetPlatform.iOS) {
                var list = new EditableListView<Object> ();
                list.SetBinding (EditableListView<Object>.SourceProperty, "JellyBeanValues");
                list.ViewType = typeof(JellyBeanListViewCell);
                list.CellHeight = 60;
                list.AddRowCommand = new Command (() => {
                    this.DisplayAlert ("Sorry", "Not implemented yet!", "OK");
                });

                if (PageModel.JellyBeanValues != null)
                    list.Source = PageModel.JellyBeanValues;
                Content = list;
            } else {
                var list = new ListView();
                list.SetBinding (ListView.ItemsSourceProperty, "JellyBeanValues");
                var celltemp = new DataTemplate(typeof(TextCell));
                celltemp.SetBinding (TextCell.TextProperty, "Name");
                celltemp.SetBinding (TextCell.DetailProperty, "ReadableValues");
                list.ItemTemplate = celltemp;
                if (PageModel.JellyBeanValues != null)
                    list.ItemsSource = PageModel.JellyBeanValues;
                Content = list;
            }

            ToolbarItems.Add(new ToolbarItem("Add", "", () => {
                this.DisplayAlert("Sorry", "Not implemented yet!", "OK");
            }));
        }
        public KnockoutMatchView()
        {
            BindingContext = new KnockoutMatchesViewModel();
            var refresh = new ToolbarItem {
                Command = ViewModel.LoadItemsCommand,
                Icon = "refresh.png",
                Name = "refresh",
                Priority = 0
            };
            ToolbarItems.Add (refresh);

            var stack = new StackLayout {
                Orientation = StackOrientation.Vertical,
                Padding = new Thickness(0, 8, 0, 8)
            };

            var listView = new ListView ();

                   listView.ItemsSource = ViewModel.KnockoutMatches;

            var cell = new DataTemplate(typeof(ListTextCell));

            cell.SetBinding (TextCell.TextProperty, "KnockoutMatchName");
            cell.SetBinding (TextCell.DetailProperty, "KnockoutMatchTeams");

            listView.ItemTemplate = cell;

            stack.Children.Add (listView);

            Content = stack;
        }
Esempio n. 4
0
        public static UIView DataTemplateToNativeView(this Xamarin.Forms.DataTemplate dt, object bindingContext, Xamarin.Forms.View rootView)
        {
            if (dt == null)
            {
                return(null);
            }
            object content = (dt is DataTemplateSelector dts)
                ? dts.SelectTemplate(bindingContext, rootView)
                : dt.CreateContent();

            View view;

            switch (content)
            {
            case ViewCell viewCell:
                viewCell.Parent         = rootView;
                viewCell.BindingContext = bindingContext;
                view = viewCell.View;
                break;

            case View view1:
                view1.Parent         = rootView;
                view1.BindingContext = bindingContext;
                view = view1;
                break;

            default:
                return(null);
            }

            return(new FormsViewContainer
            {
                View = view
            });
        }
        public SchoolPickerPage(LoginPage page)
        {
            InitializeComponent ();

            _Context = SynchronizationContext.Current;
            Search.TextChanged += (object sender, TextChangedEventArgs e) =>
            {
                if ((DateTime.Now - _PreviousGet).TotalSeconds < 4 && Search.Text.Length > 3)
                {
                    GetSchoolData();
                    _PreviousGet = DateTime.Now;
                }
            };

            Search.SearchButtonPressed += (object sender, EventArgs e) => {
                GetSchoolData();
                _PreviousGet = DateTime.Now;
            };

            var SchoolTemplate = new DataTemplate (typeof(Xamarin.Forms.TextCell));
            SchoolTemplate.SetBinding (TextCell.TextProperty, new Binding ("Name"));
            SchoolTemplate.SetBinding (TextCell.DetailProperty, new Binding ("Url"));
            Results.ItemTemplate = SchoolTemplate;

            Results.ItemTapped += (object sender, ItemTappedEventArgs e) => {
                page.SelectSchool((Magister.School)e.Item);
                Navigation.PopModalAsync();
            };
        }
		public CodedPage ()
		{
			_SomeLabel = new Label {
				XAlign = TextAlignment.Center,
			};
			_SomeLabel.SetBinding (Label.TextProperty, nameof (SomeViewModel.SomeLabel));

			var listViewItemTemplate = new DataTemplate (typeof(ImageCell));
			_ItemsListView = new ListView (ListViewCachingStrategy.RecycleElement) {
				ItemTemplate = listViewItemTemplate,
			};
			_ItemsListView.SetBinding (ListView.ItemsSourceProperty, nameof (SomeViewModel.SomeItems));
			listViewItemTemplate.SetBinding (ImageCell.TextProperty, nameof (SomeItem.ItemName));
			listViewItemTemplate.SetBinding (ImageCell.ImageSourceProperty, nameof (SomeItem.ImageUrl));
			_ItemsListView.ItemTapped += async (sender, e) => {
				var item = ((SomeItem)e.Item);
				ItemSelected (this, item);
				_ItemsListView.SelectedItem = null;
			};

			Padding = new Thickness (0, 20, 0, 0);
			Content = new StackLayout {
				VerticalOptions = LayoutOptions.Fill,
				HorizontalOptions = LayoutOptions.Fill,
				Children = {
					_SomeLabel,
					_ItemsListView,
				}
			};
		}
Esempio n. 7
0
        public JBEventsPage()
        {
            Title = "List of Jailbreak Events";

            lv = new ListView();

            var cell = new DataTemplate(typeof(TextCell));
            //use the two lines below if you want to use the default text property
            //cell.SetBinding(TextCell.TextProperty, "summary"); //the word Text here represents the field in the Database we want returned
            //lv.ItemTemplate = cell;
            //end two lines commentary

            lv.ItemTemplate = new DataTemplate(typeof(JBEventCell));

            lv.ItemSelected += (sender, e) => {
                Navigation.PushAsync(new EventDetails(e.SelectedItem as JBEvent.Item));
            };

            Content = new StackLayout
            {
                Padding = new Thickness(0, Device.OnPlatform(0, 0, 0), 0, 0),
                Spacing = 3,
                Orientation = StackOrientation.Vertical,
                Children = {
                    lv
                }
            };
        }
Esempio n. 8
0
        private void SetupUI()
        {
            BackgroundColor = Color.White;

            var cell = new DataTemplate (typeof(HiveListCell));
            cell.SetBinding (HiveListCell.HeadingTextProperty, "DisplayName");
            cell.SetBinding (HiveListCell.MiddleTextProperty, "ReadDate");
            cell.SetBinding (HiveListCell.LowerTextProperty, "Humidity");
            //			cell.SetBinding (HiveListCell.BottomTextProperty, "Humidity");
            //cell.SetBinding (HiveListCell.BottomUUIDProperty, "DisplayUUIDName");
            //cell.SetBinding (HiveListCell.HiveAddressProperty, "Address");

            listOfReadings = new ListView (ListViewCachingStrategy.RetainElement);
            listOfReadings.HasUnevenRows = true;
            listOfReadings.BindingContext = ListReadings;
            listOfReadings.SetBinding (ListView.ItemsSourceProperty, ".");
            listOfReadings.ItemTemplate = cell;
            listOfReadings.BackgroundColor = Color.White;

            Content = new StackLayout {
                Children = {
                    listOfReadings
                },
                Padding = new Thickness (0, 0, 0, 1)
            };
        }
        public GroupMatchView()
        {
            BindingContext = new GroupMatchesViewModel();

            var activity = new ActivityIndicator
            {
                Color = Helpers.Color.Greenish.ToFormsColor(),
                IsEnabled = true
            };
            activity.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
            activity.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");

            this.Groups = new ObservableCollection<GroupHelper>();
            var refresh = new ToolbarItem
            {
                Command = ViewModel.LoadItemsCommand,
                Icon = "refresh.png",
                Name = "refresh",
                Priority = 0
            };
            ToolbarItems.Add(refresh);

            ViewModel.ItemsLoaded += new EventHandler((sender, e) =>
            {
                this.Groups.Clear();
                ViewModel.Result.Select(r => r.MatchDate).Distinct().ToList()
                    .ForEach(r => Groups.Add(new GroupHelper(r)));
                foreach (var g in Groups)
                {
                    foreach (var match in ViewModel.Result.Where(m=> m.MatchDate == g.Date))
                    {
                        g.Add(match);
                    }
                }
            });

            Title = "Group Match Schedule";
            var stack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Padding = new Thickness(0, 0, 0, 8)
            };

            var listView = new ListView
            {
                IsGroupingEnabled = true,
                GroupDisplayBinding = new Binding("Date"),
            };

            var viewTemplate = new DataTemplate(typeof(ScoreCell));

            listView.ItemTemplate = viewTemplate;

            listView.ItemsSource = Groups;
            stack.Children.Add(activity);

            stack.Children.Add(listView);

            Content = stack;
        }
Esempio n. 10
0
 public LeadListView()
 {
     HasUnevenRows = false; // Circumvents calculating heights for each cell individually. The rows of this list view will have a static height.
     RowHeight = RowSizes.LargeRowHeightInt; // set the row height for the list view items
     SeparatorVisibility = SeparatorVisibility.None; // make the row separators invisible, per the intended design of this app
     ItemTemplate = new DataTemplate(typeof(LeadListItemCell));
 }
Esempio n. 11
0
        public ContactsPage()
        {
            contactsList = new ListView();

            var cell = new DataTemplate(typeof(TextCell));

            cell.SetBinding(TextCell.TextProperty, "FirstName");
            cell.SetBinding(TextCell.DetailProperty, "LastName");

            contactsList.ItemTemplate = cell;

            contactsList.ItemSelected += (sender, args) =>
            {
                if (contactsList.SelectedItem == null)
                    return;

                var contact = contactsList.SelectedItem as Contact;

                Navigation.PushAsync(new ContactPage(contact));

                contactsList.SelectedItem = null;
            };

            Content = contactsList;
        }
Esempio n. 12
0
        public MenuListTemplate()
        {
            List<MenuItem> data = new MenuListData();
            this.ItemsSource = data;
            this.VerticalOptions = LayoutOptions.FillAndExpand;
            this.BackgroundColor = Theme.NavBackgroundColor;
            this.SeparatorColor = Color.Black;
            this.Margin = new Thickness(5);

            var menuDataTemplate = new DataTemplate(() =>
            {
                var pageImage = new Image
                {
                    VerticalOptions = LayoutOptions.Center,
                    HeightRequest = 30,
                    Margin = new Thickness(0, 0, 10, 0)
                };
                var pageLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    TextColor = Theme.TextColor,
                    FontSize = 20,
                };

                pageImage.SetBinding(Image.SourceProperty, "IconSource");
                pageLabel.SetBinding(Label.TextProperty, "Name");

                var layout = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    VerticalOptions = LayoutOptions.Center,
                    Children =
                    {
                        pageImage,
                        pageLabel
                    }
                };

                var menuFrame = new Frame
                {
                    OutlineColor = Theme.NavBackgroundColor,
                    BackgroundColor = Theme.NavBackgroundColor,
                    VerticalOptions = LayoutOptions.Center,
                    Padding = new Thickness(10),
                    Content = layout
                };

                return new ViewCell { View = menuFrame };
            });



            var cell = new DataTemplate(typeof(ViewCell));
            cell.SetBinding(TextCell.TextProperty, "Name");
            cell.SetValue(TextCell.TextColorProperty, Color.FromHex("2f4f4f"));


            this.ItemTemplate = menuDataTemplate;
            this.SelectedItem = data[0];
        }
Esempio n. 13
0
        public RssFeedView2()
        {
            this.viewModel = new RssFeedViewModel();
            this.BindingContext = viewModel;
            this.Title = "Rss Feed";

            var refresh = new ToolbarItem(){ Command = viewModel.ReloadCommand, Name = "Reload", Priority = 0 };
            ToolbarItems.Add(refresh);

            var stack = new StackLayout(){ Orientation = StackOrientation.Vertical };
            var activity = new ActivityIndicator(){ Color = Color.Blue, IsEnabled = true };
            activity.SetBinding(ActivityIndicator.IsVisibleProperty, "ShowActivityIndicator");
            activity.SetBinding(ActivityIndicator.IsRunningProperty, "ShowActivityIndicator");

            stack.Children.Add(activity);

            var listview = new ListView();
            listview.ItemsSource = viewModel.Records;
            var cell = new DataTemplate(typeof(ImageCell));
            cell.SetBinding(ImageCell.TextProperty, "Title");
            cell.SetBinding(ImageCell.ImageSourceProperty, "Image");
            listview.ItemTemplate = cell;
            listview.ItemSelected += async (sender, e) => {
                await Navigation.PushAsync(new RssWebView((RssRecordViewModel)e.SelectedItem));
                listview.SelectedItem = null;
            };

            stack.Children.Add(listview);

            Content = stack;
        }
Esempio n. 14
0
		private async Task Init ()
		{
			_conferencesListView = new ListView { 
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
			};

			var cell = new DataTemplate (typeof(TextCell));
			cell.SetBinding (TextCell.TextProperty, "Name");
			cell.SetBinding (TextCell.DetailProperty, new Binding (path: "Start", stringFormat: "{0:MM/dd/yyyy}"));

			_conferencesListView.ItemTemplate = cell;

			var viewModel = new ConferencesViewModel ();
			await viewModel.GetConferences ();
			_conferencesListView.ItemsSource = viewModel.Conferences;

			this.Content = new StackLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
				Padding = new Thickness (
					left: 0, 
					right: 0, 
					bottom: 0, 
					top: Device.OnPlatform (iOS: 20, Android: 0, WinPhone: 0)),
				Children = { 
					_conferencesListView 
				}
			};
		}
Esempio n. 15
0
		private void SetupUserInterface ()
		{
			var itemTemplate = new DataTemplate (typeof(MomentCell));

			momentsListView = new ListView {
				BackgroundColor = Color.White,
				IsPullToRefreshEnabled = true,
				ItemTemplate = itemTemplate,
				ItemsSource = ViewModel.Moments,
				RowHeight = 70
			};

			momentsListView.ItemSelected += (s, e) => {
				momentsListView.SelectedItem = null;
			};

			momentsListView.ItemTapped += (s, e) => {
				var moment = e.Item as Moment;
				if (moment == null) {
					return;
				}

				App.Current.MainPage.Navigation.PushModalAsync (new ViewMomentPage (moment.MomentUrl, TimeSpan.FromSeconds (moment.DisplayTime)));
				ViewModel.DestroyImageCommand.Execute (moment);
				momentsListView.SelectedItem = null;
			};

			Content = momentsListView;
		}
Esempio n. 16
0
		public ProductPage (String uid)
		{
			Title = "Produits";
			var dataTemplate = new DataTemplate (typeof(TextCell));
			dataTemplate.SetBinding (TextCell.TextProperty, "name");
			dataTemplate.SetBinding (TextCell.DetailProperty, "price");

			list = new ListView ();
			list.ItemTemplate = dataTemplate;
			list.IsPullToRefreshEnabled = true;
			list.RefreshCommand = new Command (() => loadProductData());

			list.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => {
				if(e.SelectedItem == null)
					return;
				Product product = (Product)e.SelectedItem;
				list.SelectedItem = null;
				//TODO: implement nav to product detail page
				//this.Navigation.PushAsync (new ProductPage(category.uid));
			};

			Content = list;
			this.categoryUid = uid;
			list.BeginRefresh ();
		}
Esempio n. 17
0
 public CategoryListView()
 {
     ItemTemplate = new DataTemplate(typeof(CategoryListItemCell));
     RowHeight = (int)Sizes.LargeRowHeight;
     SeparatorVisibility = SeparatorVisibility.Default;
     SeparatorColor = Palette._013;
 }
Esempio n. 18
0
        public PFDictionaryView()
        {
            viewModel = new PFDictionaresViewModel();
            ItemsSource = viewModel.PFDictionariesGrouped;
            IsGroupingEnabled = true;
            GroupDisplayBinding = new Binding("Key");
            GroupShortNameBinding = new Binding("Key");

            if(Device.OS != TargetPlatform.WinPhone)
                GroupHeaderTemplate = new DataTemplate(typeof(HeaderCell));

             var cell = new DataTemplate(typeof(PFDictCell));

             ItemTemplate = cell;
             //SeparatorVisibility = SeparatorVisibility.None;
             RowHeight = 60;
             ItemTapped += (sender, args) =>
             {
                var pfdic = args.Item as  PFDictionary;
                if (pfdic == null)
                    return;

                //Navigation.PushAsync(new DetailsPage(pfdic));
                // Reset the selected item
                 SelectedItem = null;
            };
        }
Esempio n. 19
0
 public CustomerListView()
 {
     HasUnevenRows = false; // Circumvents calculating heights for each cell individually. The rows of this list view will have a static height.
     RowHeight = (int)Sizes.LargeRowHeight; // set the row height for the list view items
     ItemTemplate = new DataTemplate(typeof(CustomerListItemCell));
     SeparatorColor = Palette._013;
 }
Esempio n. 20
0
        /** Create Tag List stack
         **/
        public StackLayout createTagListStack(Button done)
        {
            // Initialise tags
            Tags[] tagAr = initTags ();

            // Create the shown elements
            ListView lView = new ListView {
                BackgroundColor = Color.FromHex("#007064"),
            };

            // Setup those elements
            lView.ItemSelected += noSelection;
            lView.ItemTapped += tappedSelection;

            DataTemplate template = new DataTemplate (typeof (customCellTags));

            lView.ItemsSource = tagAr;
            lView.ItemTemplate = template;

            // Create the layout to show those elements
            StackLayout options = new StackLayout {
                Spacing = 15,
                Padding = new Thickness(15,15,15,15),
                VerticalOptions = LayoutOptions.StartAndExpand,
                Orientation = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.EndAndExpand,
                Children = {lView, done}
            };
            return options;
        }
Esempio n. 21
0
        /// <summary>
        /// Menu Page Layout.
        /// </summary>
        public void MenuLayout()
        {
            List<MenuModel> data = MenuModel.MenuListData();

            listMenu = new ListView { RowHeight = 40, SeparatorColor = Color.FromHex("#5B5A5F") };

            listMenu.VerticalOptions = LayoutOptions.FillAndExpand;
            listMenu.BackgroundColor = Color.Transparent;

            listMenu.ItemsSource = data;

            var cell = new DataTemplate(typeof(MenuCell));
            cell.SetBinding(MenuCell.TextProperty, "Title");
            cell.SetBinding(MenuCell.ImageSourceProperty, "IconSource");

            listMenu.ItemTemplate = cell;

            //var menuLabel = new ContentView
            //{
            //    Padding = new Thickness(10, 36, 0, 5),
            //    Content = new Label
            //    {
            //        TextColor = Color.FromHex("AAAAAA"),
            //        Text = "MENU",
            //    }
            //};

            this.Content = new StackLayout
            {
                BackgroundColor = Color.White,
                Children = { listMenu }
            };
        }
        public EventListView(EventViewModel viewModel)
        {
            BindingContext = viewModel;

            var stack = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Padding = new Thickness(0, 10)
            };

            var progress = new ActivityIndicator
            {
                IsEnabled = true,
                Color = Color.White
            };

            progress.SetBinding(IsVisibleProperty, "IsBusy");
            progress.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");

            stack.Children.Add(progress);

            var listView = new ListView {ItemsSource = viewModel.Events};

            var itemTemplate = new DataTemplate(typeof (TextCell));
            itemTemplate.SetBinding(TextCell.TextProperty, "Name");
            listView.ItemTemplate = itemTemplate;

            stack.Children.Add(listView);

            Content = stack;
        }
Esempio n. 23
0
        public ListaNotificaciones()
        {
            //notificaciones = new Notificacion ("Red Social","BtoB");

            var cell = new DataTemplate (typeof(TextCell));

            cell.SetBinding (TextCell.TextProperty, "Title");
            cell.SetBinding (TextCell.DetailProperty, "Subtitle");

            ItemTemplate = cell;

            var loc = new List<Notificacion> () {
                new Notificacion ("Abercrombie & Fitch / abercrombie kids", "Level 2 | (480) 792-9275"),
                new Notificacion ("ALDO", "Level 2 | (480) 899-0803"),
                new Notificacion ("All Mobile Matters Mobile Phone Repair & More", "Level 2 | (480) 228-9690"),
                new Notificacion ("Alterations By L", "Level 1 | (480) 786-8092"),
                new Notificacion ("AMERICAN EAGLE OUTFITTERS", "Level 2 | (480) 812-0090"),
                new Notificacion ("Ann Taylor", "Level 1 | (480) 726-6944"),
                new Notificacion ("Apex by sunglass hut", "Level 2 | (480) 855-1709")
            };

            ItemsSource = loc;

            /*ItemSelected += (s, e) => {
                if (SelectedItem == null)
                    return;
                var selected = (Notificacion)e.SelectedItem;
                SelectedItem = null;
                //Navigation.PushAsync (new CampusLocationPage (selected));
            };*/
        }
        public SessionsMenuPage()
        {
            //TODO : Step 03-3 - Add menu button
            //Title = "Menu";

            //TODO : Step 03-8 - Add menu button
            //Icon = "sessions.png";

            #region Initialize Page
            this.Padding = new Thickness (0, Device.OnPlatform (40, 0, 0), 0, 0);

            var sessions = Repository.GetSessions ();

            var cell = new DataTemplate (typeof(TextCell));
            cell.SetBinding (TextCell.TextProperty, "Title");

            var listView = new ListView {
                ItemsSource = sessions,
                ItemTemplate = cell
            };
            #endregion

            //TODO : Step 03-4 - Send event when item selected
            //			listView.ItemSelected += (sender, args) => {
            //				if (args.SelectedItem != null) {
            //					MessagingCenter.Send (new SessionSelected (args.SelectedItem as Session), "SessionSelected");
            //					listView.SelectedItem = null;
            //				}
            //			};

            Content = listView;
        }
        public MenuPage()
        {
            InitializeComponent ();

            _viewModel = new MenuPageViewModel ();
            this.BindingContext = _viewModel;

            var cell = new DataTemplate (typeof(MenuPageViewCell));
            // cell.SetBinding (SwitchCell.TextProperty, "TestoVoceDiMenu");
            // cell.SetBinding (SwitchCell.OnProperty, "Attivato");
            // cell.SetBinding (SwitchCell, "Immagine");
            ListaVociMenu.ItemTemplate = cell;
            ListaVociMenu.RowHeight = 80;

            ListaVociMenu.SetBinding<MenuPageViewModel> (ListView.ItemsSourceProperty,
                c => c.Lista, BindingMode.OneWay);

            Title = "App";
            BackgroundColor = Color.Gray;

            ListaVociMenu.ItemTapped += (object sender, ItemTappedEventArgs e) => {
                var elementoscelto = (MenuListItem)e.Item;

                ListaVociMenu.SelectedItem = null;
                if (EventoVoceSelezionata != null)
                    EventoVoceSelezionata(elementoscelto.IdVoceDiMenu);
            };
        }
        public FootballPlayerListPage()
        {
            this.BindingContext = new FootballPlayerViewModel ();

            Title = "Football Legends";
            var create = new ToolbarItem ();
            create.Name = "create";

            this.ToolbarItems.Add (create);
            create.Clicked += Create_Clicked;
            //	create.SetBinding (ToolbarItem.CommandProperty, "CreatePlayer");
            MyFootballList = new ListView ();
            MyFootballList.IsPullToRefreshEnabled = true;
            MyFootballList.Refreshing += MyFootballList_Refreshing;
            MyFootballList.SetBinding (ListView.ItemsSourceProperty, "Footballplayercollection");
            var cell = new DataTemplate (typeof(FootballPlayerListCell));
            MyFootballList.ItemTemplate = cell;
            MyFootballList.RowHeight = 70;

            MessagingCenter.Subscribe<FootballPlayerListCell>(this,"delete",(sender) => {
                this.BindingContext = new FootballPlayerViewModel();
                FootballPlayer dat= new FootballPlayer ();
                MyFootballList.ItemsSource = dat.GetItems ();

            },null);

            MyFootballList.ItemSelected += (object sender, SelectedItemChangedEventArgs e) =>
            {

                Navigation.PushAsync(new FootballPlayerDetailPage(e.SelectedItem));

            };

            this.Content = MyFootballList;
        }
Esempio n. 27
0
		public MenuPage ()
		{
			Title = "Menu";
			Icon = "menu.png";

			Padding = new Thickness (10, 20);

			var categories = new List<Category> () {
				new Category("Food", () => new FoodCategoryPage()),
				new Category("Shopping", () => new ShoppingCategoryPage()),
				new Category("Sports", () => new SportsCategoryPage())
			};

			var dataTemplate = new DataTemplate (typeof(TextCell));
			dataTemplate.SetBinding (TextCell.TextProperty, "Name");

			var listView = new ListView () {
				ItemsSource = categories,
				ItemTemplate = dataTemplate
			};

			listView.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => {
				if (OnMenuSelect != null)
				{
					var category = (Category) e.SelectedItem;
					var categoryPage = category.PageFn();
					OnMenuSelect(categoryPage);
				}				
			};


			Content = listView;
		}
		private async Task RefreshAsync()
		{
			listView.ItemsSource = await App.CustManager.GetTasksAsync ();

			var cell = new DataTemplate (typeof(TextCell));
			listView.ItemTemplate = new DataTemplate (typeof(CustomerCell));
		}
		public SportsCategoryPage ()
		{
			Title = "Sports";

			Padding = new Thickness (10, 20);

			var places = new List<Place> () 
			{
				new Place("The Gulf Bowl", "gulfBowl.jpg", "2881 S Juniper St, Foley, AL"),
				new Place("Foley Sports Complex", "foleySportsComplex.jpg", "998 W Section Ave, Foley, AL"),
				new Place("Swatters Sports Complex", "swattersSportsComplex.jpg", "21431 Co Rd 12 S Foley, AL")
			};

			var imageTemplate = new DataTemplate (typeof(ImageCell));
			imageTemplate.SetBinding (ImageCell.TextProperty, "Name");
			imageTemplate.SetBinding (ImageCell.ImageSourceProperty, "Icon");
			imageTemplate.SetBinding (ImageCell.DetailProperty, "Address");

			var listView = new ListView () 
			{
				ItemsSource = places,
				ItemTemplate = imageTemplate
			};

			Content = listView;
		}
Esempio n. 30
0
        public FeedOverview()
        {
            var refreshButton = new Button {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.Center,
            Text = "Refresh"
              };
              refreshButton.SetBinding(Button.CommandProperty, "RefreshCommand");

              var template = new DataTemplate(typeof(TextCell));
              // We can set data bindings to our supplied objects.
              template.SetBinding(TextCell.TextProperty, "Title");
              template.SetBinding(TextCell.DetailProperty, "Description");

              var listView = new ListView {ItemTemplate = template};
              listView.SetBinding(ListView.ItemsSourceProperty, "FeedItems");

              // Push the list view down below the status bar on iOS.
              Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
              Content = new Grid {
            BindingContext = new FeedReaderViewModel(),

            RowDefinitions = new RowDefinitionCollection {
             new RowDefinition { Height = new GridLength (1, GridUnitType.Star) },
             new RowDefinition { Height = new GridLength (0, GridUnitType.Auto) },

               },
            Children = {
               new ViewWithGridPosition(listView, 0,0),
               new ViewWithGridPosition(refreshButton, 1,0)
             },
              };
        }
Esempio n. 31
0
        public void Init()
        {
            this.SeparatorVisibility    = SeparatorVisibility.None;
            this.HasUnevenRows          = true;
            this.IsPullToRefreshEnabled = true;

            ItemTemplate = new Xamarin.Forms.DataTemplate(typeof(RequestListDataTemplate));
        }
 public bool Add(XRF.DataTemplate template, int index, object child, IComponentAdapterController rootAdapter, bool @throw = true)
 {
     if (template.ChildContent == null && template.Template == null)
     {
         throw new InvalidOperationException($"{typeof(XF.DataTemplate)} must have either ChildContent or Type set");
     }
     if (child != null)
     {
         //since DataTemplate is constructed in razor, the default constructor was used and this has no child element.
         //We make a new template
         //Also since datatemplate needs to be repeated for each item, the element passed here is useless
         //we create a new element in the DataTemplate Action
         XF.DataTemplate newDataTemplate = null;
         //try and guess the best root element for the data template by pre-rendering it and checking the type of the root element
         //var root = Razor.Create<object>(rootAdapter.ServiceProvider, template.ChildContent).Result;
         //if (template.ChildContent != null)
         //{
         if (child is XRF.ViewCell viewCell)
         {
             newDataTemplate = new XF.DataTemplate(() =>
             {
                 return(new CaptureCurrentObjectForViewCell(rootAdapter.ServiceProvider, viewCell.ChildContent));
             });
         }
         else if (child is XF.Element element)
         {
             newDataTemplate = new XF.DataTemplate(() =>
             {
                 return(element);
             });
         }
         //}
         //var newDataTemplate = new XF.DataTemplate(() =>
         //{
         //    return Razor.Create<DataTemplateComponent, Element>(rootAdapter.ServiceProvider, (t) =>
         //    {
         //        t.ChildContent = view.ChildContent;
         //    }).Result;
         //});
         //now we need to replace the old template with the new template
         //we find the adpater that set the old template into its parent and we ask it ro replace it
         //find the parent first
         if (newDataTemplate != null)
         {
             rootAdapter.Parent.Replace(template, new XRF.DataTemplate(newDataTemplate)
             {
                 Property = template.Property
             }, @throw);
             return(true);
         }
     }
     if (@throw)
     {
         throw new InvalidOperationException($"{typeof(XF.DataTemplate)} doesn't supports ChildContent of type {child.GetType()}");
     }
     return(false);
 }
 //since we defer the call o childcontent of datatemplate to prevent passing null parameter to the user provided template,
 //we have to process the DaatTemplate here else exception "LoadTemplate should not be null"
 public object Adapt(DataTemplate component, IComponentAdapterController rootAdapter)
 {
     if (component.Template == null && component.ChildContent == null)
     {
         throw new InvalidOperationException("DataTemplate must have either a Type or a ChildContent");
     }
     XF.DataTemplate newDataTemplate = null;
     if (component is DataTemplateTBase tbase && tbase.TemplateChildContent != null)
     {
         newDataTemplate = new XF.DataTemplate(() =>
         {
             return(new CaptureCurrentObjectForDataTemplateAsContentView(rootAdapter.ServiceProvider, tbase.TemplateChildContent));
         });
     }
Esempio n. 34
0
		public static void SetMenuItemTemplate(BindableObject obj, DataTemplate menuItemTemplate) => obj.SetValue(MenuItemTemplateProperty, menuItemTemplate);
Esempio n. 35
0
		public static void SetItemTemplate(BindableObject obj, DataTemplate itemTemplate) => obj.SetValue(ItemTemplateProperty, itemTemplate);
Esempio n. 36
0
 public static void SetItemTemplate(BindableObject b, DataTemplate value)
 {
     b.SetValue(ItemTemplateProperty, value);
 }
Esempio n. 37
0
        private StackLayout AddListView()
        {
            var personDataTemplate = new Xamarin.Forms.DataTemplate(() =>
            {
                var stackMain = new StackLayout
                {
                    Spacing           = 0,
                    Padding           = new Thickness(10, 10, 10, 0),
                    Orientation       = StackOrientation.Vertical,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.Start,
                    Children          = { StackColumContentMessage() }
                };

                //Image image = new Image() { Aspect = Aspect.AspectFit, Source = "https://picsum.photos/150/150/?random" };

                var nomeLabel = new Label {
                    FontAttributes = FontAttributes.Bold, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
                };
                var idadeLabel = new Label()
                {
                };
                var serieLabel = new Label {
                    HorizontalTextAlignment = TextAlignment.End,

                    FontAttributes = FontAttributes.Bold,
                    FontSize       = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
                };

                nomeLabel.SetBinding(Label.TextProperty, "Nome");
                idadeLabel.SetBinding(Label.TextProperty, "Idade");
                serieLabel.SetBinding(Label.TextProperty, "Serie");


                return(new ViewCell {
                    View = stackMain
                });
            });


            var lblDataNotificacao = new Label
            {
                FontSize                = 9,
                HorizontalOptions       = LayoutOptions.End,
                HorizontalTextAlignment = TextAlignment.End
            };

            var lblAssunto = new Label
            {
                FontSize      = 11,
                LineBreakMode = LineBreakMode.TailTruncation
            };

            lblAssunto.SetBinding(Label.TextProperty, "Nome");

            var lblContent = new Label
            {
                LineBreakMode           = LineBreakMode.TailTruncation,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Start
            };

            lblContent.FontSize = Device.GetNamedSize(NamedSize.Medium, lblContent);

            lblContent.SetBinding(Label.TextProperty, "Serie");

            var contentMensage = new StackLayout
            {
                Spacing           = 0.4,
                Padding           = new Thickness(5, 5, 0, 0),
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            contentMensage.Children.Add(new StackLayout
            {
                Children          = { lblDataNotificacao },
                HorizontalOptions = LayoutOptions.End
            });

            contentMensage.Children.Add(lblAssunto);
            contentMensage.Children.Add(lblContent);

            return(contentMensage);
        }
Esempio n. 38
0
		void OnHeaderOrFooterChanged(ref Element storage, string property, object dataObject, DataTemplate template, bool templateChanged)
		{
			if (dataObject == null)
			{
				if (!templateChanged)
				{
					OnPropertyChanging(property);
					storage = null;
					OnPropertyChanged(property);
				}

				return;
			}

			if (template == null)
			{
				var view = dataObject as Element;
				if (view == null || view is Page)
					view = new Label { Text = dataObject.ToString() };

				view.Parent = this;
				OnPropertyChanging(property);
				storage = view;
				OnPropertyChanged(property);
			}
			else if (storage == null || templateChanged)
			{
				OnPropertyChanging(property);
				storage = template.CreateContent() as Element;
				if (storage != null)
				{
					storage.BindingContext = dataObject;
					storage.Parent = this;
				}
				OnPropertyChanged(property);
			}
			else
			{
				storage.BindingContext = dataObject;
			}
		}
Esempio n. 39
-1
		protected override void Init ()
		{
			var presidents = new List<President> ();
			for (int i = 0; i < 10; i++) {
				presidents.Add (new President ($"Presidente {44 - i}", 1, $"http://static.c-span.org/assets/images/series/americanPresidents/{43 - i}_400.png"));
			}
						
			var header = new Label {
				Text = "Presidents",
				HorizontalOptions = LayoutOptions.Center
			};

			var cell = new DataTemplate (typeof(CustomCell));

			var listView = new ListView {
				ItemsSource = presidents,
				ItemTemplate = cell,
				RowHeight = 200
			};

		
			Content = new StackLayout {
				Children = {
					header,
					listView
				}
			};
		}