• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Forms.DataTemplate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



DataTemplate类属于Xamarin.Forms命名空间,在下文中一共展示了DataTemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GroupMatchView

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


示例2: LeadListView

 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));
 }
开发者ID:XnainA,项目名称:app-crm,代码行数:7,代码来源:LeadListView.cs


示例3: 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


示例4: 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


示例5: CustomerListView

 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;
 }
开发者ID:njmube,项目名称:app-crm,代码行数:7,代码来源:CustomerListView.cs


示例6: 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


示例7: Init

		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
				}
			};
		}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:28,代码来源:Issue2354.cs


示例8: FootballPlayerListPage

        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;
        }
开发者ID:CTS458641,项目名称:cts458701,代码行数:35,代码来源:FootballPlayerListPage.cs


示例9: RefreshAsync

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

			var cell = new DataTemplate (typeof(TextCell));
			listView.ItemTemplate = new DataTemplate (typeof(CustomerCell));
		}
开发者ID:fabianwilliams,项目名称:ITDevConnections2015,代码行数:7,代码来源:DisplayCustomrsPage.cs


示例10: EventListView

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


示例11: SessionsMenuPage

        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;
        }
开发者ID:flolovebit,项目名称:xamarin-evolve-2014,代码行数:32,代码来源:SessionsMenuPage.cs


示例12: createTagListStack

        /** 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;
        }
开发者ID:jarade,项目名称:IAB330Project,代码行数:32,代码来源:TagList.cs


示例13: PFDictionaryView

        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;
            };
        }
开发者ID:henrytranvan,项目名称:HSFFinance,代码行数:27,代码来源:PFDictionaryView.cs


示例14: ProductPage

		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 ();
		}
开发者ID:rgdev,项目名称:Xmazon,代码行数:25,代码来源:ProductPage.cs


示例15: 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


示例16: SetupUserInterface

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


示例17: MenuPage

        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);
            };
        }
开发者ID:maurocavallin,项目名称:CorsoXamarinGiugno2015,代码行数:28,代码来源:MenuPage.xaml.cs


示例18: CategoryListView

 public CategoryListView()
 {
     ItemTemplate = new DataTemplate(typeof(CategoryListItemCell));
     RowHeight = (int)Sizes.LargeRowHeight;
     SeparatorVisibility = SeparatorVisibility.Default;
     SeparatorColor = Palette._013;
 }
开发者ID:rrawla,项目名称:app-crm,代码行数:7,代码来源:CategoryListView.cs


示例19: MenuPage

		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;
		}
开发者ID:menoret-allan,项目名称:MyXamarinSamples,代码行数:33,代码来源:MenuPage.cs


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Forms.Grid类代码示例发布时间:2022-05-26
下一篇:
C# Forms.ContentView类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap