当前位置: 首页>>代码示例>>C#>>正文


C# DataTemplate.SetBinding方法代码示例

本文整理汇总了C#中Xamarin.Forms.DataTemplate.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# DataTemplate.SetBinding方法的具体用法?C# DataTemplate.SetBinding怎么用?C# DataTemplate.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Xamarin.Forms.DataTemplate的用法示例。


在下文中一共展示了DataTemplate.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CodedPage

		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,
				}
			};
		}
开发者ID:patridge,项目名称:demos-xamarin.forms-tour,代码行数:30,代码来源:CodedPage.cs

示例2: Init

		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 
				}
			};
		}
开发者ID:RobGibbens,项目名称:DtoToVM,代码行数:29,代码来源:ConferencesPage.cs

示例3: FcpChampions

		///<summary>FcpChampions: Displays a listview of all champions.
		///<para>[Navigation] From: MainPage / Calls: FcpTabChampions</para>
		///</summary>
		public FcpChampions() {
			//NavigationPage.SetBackButtonTitle(this, "Back to menu");
			this.Title = "Champions";
			stacklayout.VerticalOptions = LayoutOptions.FillAndExpand;
			stacklayout.BackgroundColor = Color.Red ;
			//ReadChampionJson();
			//ReceiveChampions();
			FillViewChampions();

			var cell = new DataTemplate(typeof(ImageCell));
			cell.SetBinding(ImageCell.ImageSourceProperty, "Image");
			cell.SetBinding(TextCell.TextProperty, "Name");
			cell.SetBinding(TextCell.TextColorProperty, "Color");

			listview.ItemTemplate = cell;
			listview.ItemsSource = Cells;
			listview.ItemTapped += Listview_ItemTapped;
			listview.BackgroundColor = Color.Black;			
			searchbar.Placeholder = "Find champion";
			searchbar.TextChanged += Searchbar_TextChanged;
			searchbar.BackgroundColor = Color.Black;

			Content = stacklayout;
			stacklayout.Children.Add(searchbar);
			stacklayout.Children.Add(listview);			
        }
开发者ID:Vorkeal,项目名称:LeagueStatsMobile,代码行数:29,代码来源:FcpChampions.cs

示例4: ContactsPage

        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;
        }
开发者ID:Jazzeroki,项目名称:Xamarin.Plugins,代码行数:25,代码来源:ContactsPage.cs

示例5: RssFeedView2

        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;
        }
开发者ID:jeffbmiller,项目名称:RSSFeeds,代码行数:31,代码来源:RssFeedView2.cs

示例6: FoodCategoryPage

		public FoodCategoryPage ()
		{
			Title = "Food";

			Padding = new Thickness (10, 20);

			var places = new List<Place> () 
			{
				new Place("McDonalds", "mcdonalds.png", "1010 S McKenzie St Foley, AL"),
				new Place("Burger King", "burgerKing.png", "910 S McKenzie St Foley AL"),
				new Place("Apple Bees", "appleBees.png", "2409 S McKenzie St, Foley, AL"),
				new Place("Taco Bell", "tacoBell.jpg", "1165 S McKenzie St, Foley, AL"),
				new Place("Subway", "subway.jpg", "610 S McKenzie St 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;
		}
开发者ID:menoret-allan,项目名称:MyXamarinSamples,代码行数:28,代码来源:FoodCategoryPage.cs

示例7: SetupUI

        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)
            };
        }
开发者ID:codemillmatt,项目名称:Rx-Cure,代码行数:26,代码来源:HiveList.cs

示例8: KnockoutMatchView

        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;
        }
开发者ID:AjourMedia,项目名称:FootballTournament2014,代码行数:31,代码来源:KnockoutMatchView.cs

示例9: Init

        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");
            }));
        }
开发者ID:rid00z,项目名称:JellyBeanTracker,代码行数:30,代码来源:JellyBeanListPage.cs

示例10: ListaNotificaciones

        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));
            };*/
        }
开发者ID:jupabequi,项目名称:COLPLATP20,代码行数:31,代码来源:ListaNotificaciones.cs

示例11: FeedOverview

        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)
             },
              };
        }
开发者ID:dotnetautor,项目名称:FeedReader2015,代码行数:33,代码来源:FeedOverview.cs

示例12: SchoolPickerPage

        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();
            };
        }
开发者ID:matthijsotterloo,项目名称:Schoolmaster-Hackathon,代码行数:29,代码来源:SchoolPickerPage.xaml.cs

示例13: Offers

		public Offers ()
		{

			//commented out dummy offers
			//setOffers ();

			Title = "Offers";
			Icon = "Offers.png";


			// Create a data template from the type ImageCell
			var cell = new DataTemplate (typeof(ImageCell));

			cell.SetBinding (TextCell.TextProperty, "Name");
			cell.SetBinding (TextCell.DetailProperty,"Description");
			cell.SetBinding (ImageCell.ImageSourceProperty, "Image");

			ListView listView = new ListView {
				ItemsSource = offers,
				ItemTemplate = cell // Set the ImageCell to the item template for the listview
			};

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

			// Set the content for the page.
			this.Content = new StackLayout {
				Children = {
					//header,
					listView
				}
			};

		}
开发者ID:gregackerman,项目名称:plentyxam,代码行数:34,代码来源:Offers.cs

示例14: MenuLayout

        /// <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 }
            };
        }
开发者ID:pratik8490,项目名称:TextShield,代码行数:36,代码来源:MenuPage.cs

示例15: ListViewEx

        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;
        }
开发者ID:mkonkolowicz,项目名称:KnockKnock,代码行数:25,代码来源:ListViewEx.cs


注:本文中的Xamarin.Forms.DataTemplate.SetBinding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。