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


C# DataTemplate.SetValue方法代码示例

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


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

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

示例2: Init

        private async Task Init()
        {
            _itemSelectedEventHandler = (sender, args) =>
            {
                if (args.SelectedItem == null)
                    return;

                var selectedItem = args.SelectedItem as ResourceListItemViewModel;

                Navigation.PushAsync(new ResourceViewPage(selectedItem));

            };

            BackgroundColor = Constants.HtBoxDarkBrown;

            Padding = new Thickness(0, Device.OnPlatform(20,0,0), 0, 0);

            Title = "Resources for: Big Disaster"; //TODO - Add Disaster Name

            // TODO: Get data from the API
            //ICrisisCheckInApiClient apiClient = new CrisisCheckInApiClient();
            //var dtos = await apiClient.GetCommitmentsList(2); //TODO: wire up to Auth0 so we don't have to pass person ID
            //Data = dtos.Select(c => new DisasterListItemViewModel(c));

            ResourceList = new List<ResourceListItemViewModel>
            {
                new ResourceListItemViewModel
                {
                    Description = "Dump Truck",
                    Type = "Heavy Machines",
                    PersonFullName = "Bob Smith",
                    Location_State = "Maine",
                    Qty = 2
                },
                 new ResourceListItemViewModel
                {
                    Description = "Poland Spring Water",
                    Type = "Water",
                    PersonFullName = "Mike Smith",
                    Location_State = "Maine",
                    Qty = 500
                }
            };

            _resourceListView = new ListView
            {
                ItemsSource = ResourceList,
                BackgroundColor = Constants.HtBoxDarkBrown
            };
            _resourceListView.ItemSelected += _itemSelectedEventHandler;
            var cell = new DataTemplate(typeof(TextCell));
            cell.SetBinding(TextCell.TextProperty, new Binding("Type"));
            cell.SetBinding(TextCell.DetailProperty, new Binding("Description"));
            cell.SetValue(TextCell.TextColorProperty, Color.White);
            cell.SetValue(TextCell.DetailColorProperty, Constants.HtBoxLightBrown);
            _resourceListView.ItemTemplate = cell;

            Content = _resourceListView;
        }
开发者ID:mjmilan,项目名称:crisischeckin,代码行数:59,代码来源:ResourceListPage.cs

示例3: CreateRequestCell

 private DataTemplate CreateRequestCell()
 {
     var cell = new DataTemplate(typeof (TextCell));
     cell.SetBinding(TextCell.TextProperty, new Binding("Description"));
     cell.SetBinding(TextCell.DetailProperty, new Binding("Location"));
     cell.SetValue(TextCell.TextColorProperty, Color.White);
     cell.SetValue(TextCell.DetailColorProperty, Constants.HtBoxLightBrown);
     return cell;
 }
开发者ID:mjmilan,项目名称:crisischeckin,代码行数:9,代码来源:RequestListPage.cs

示例4: MenuPage

        public MenuPage()
        {
            InitializeComponent();
			OptionItems.Add(new OptionItem() { Title = "Projeções" });
			OptionItems.Add(new OptionItem() { Title = "Sobre" });
			OptionItems.Add(new OptionItem() { Title = "Logout" });
			var cell = new DataTemplate(typeof(DarkTextCell));
			cell.SetBinding(TextCell.TextProperty, "Title");
			cell.SetBinding(ImageCell.ImageSourceProperty, "IconSource");
			cell.SetValue(TextCell.TextColorProperty, "#F8F8F8");
			cell.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent);
			listMenu.ItemTemplate = cell;
			listMenu.ItemsSource = OptionItems;
        }
开发者ID:vyctorbh,项目名称:arch-xamarin,代码行数:14,代码来源:MenuPage.xaml.cs

示例5: MenuListTemplate

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

示例6: MenuPage

        public MenuPage()
        {
            OptionItems.Add(new LeadsOptionItem());
            OptionItems.Add(new ContactsOptionItem());
            OptionItems.Add(new AccountsOptionItem());
            OptionItems.Add(new OpportunitiesOptionItem());

            BackgroundColor = Color.FromHex("333333");

            var layout = new StackLayout { Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand };

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

            Device.OnPlatform(
                iOS: () => ((Xamarin.Forms.Label)label.Content).Font = Font.SystemFontOfSize(NamedSize.Micro),
                Android: () => ((Xamarin.Forms.Label)label.Content).Font = Font.SystemFontOfSize(NamedSize.Medium)
            );

            layout.Children.Add(label);

            Menu = new ListView
            {
                ItemsSource = OptionItems,
                VerticalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.Transparent
            };

            var cell = new DataTemplate(typeof(DarkTextCell));
            cell.SetBinding(TextCell.TextProperty, "Title");
            cell.SetBinding(TextCell.DetailProperty, "Count");
            cell.SetBinding(ImageCell.ImageSourceProperty, "IconSource");
            cell.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent);

            Menu.ItemTemplate = cell;

            layout.Children.Add(Menu);

            Content = layout;
        }
开发者ID:mattkrebs,项目名称:MineApp,代码行数:47,代码来源:MenuPage.cs

示例7: MenuView

      public MenuView()
      {
        this.Icon = "slideout.png";
        this.Title = "menu";
        BindingContext = viewModel = new HomeViewModel();


        this.BackgroundImage = "menubk.png";



        var label = new ContentView
        {
          Padding = new Thickness(10, 36, 0, 5),
          Content = new Xamarin.Forms.Label
          {
            TextColor = Color.White,
            Text = "MENU",
          }
        };

  
        Menu = new ListView
        {
          ItemsSource = viewModel.MenuItems,
          VerticalOptions = LayoutOptions.FillAndExpand,          
          BackgroundColor = Color.Transparent,
        };

        var cell = new DataTemplate(typeof(MenuCell));
        cell.SetBinding(TextCell.TextProperty, BaseViewModel.TitlePropertyName);
        cell.SetBinding(ImageCell.ImageSourceProperty, BaseViewModel.IconPropertyName);
        cell.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent);

        Menu.ItemTemplate = cell;


        Content = new StackLayout
        {
          Spacing = 10,
          VerticalOptions = LayoutOptions.FillAndExpand,
          Children = { label, Menu}
        };
      }
开发者ID:njmube,项目名称:VervetaCRM,代码行数:44,代码来源:MenuView.cs

示例8: MenuPage

		public MenuPage ()
		{
			MenuItems.AddRange (ViewModels.MenuItem.All());

			BackgroundColor = ColorHelper.MenuBackgroundColor;

			var layout = new StackLayout { Spacing = 0, VerticalOptions = LayoutOptions.FillAndExpand };

			var headerText = new ContentView {
				Padding = new Thickness(10, 36, 0, 5),
				Content = new Xamarin.Forms.Label {
					TextColor = Color.White,
					Text = "DNA.XForms Sample", 
					Font = Font.SystemFontOfSize (NamedSize.Medium),
				}
			};

			layout.Children.Add(headerText);

			Menu = new ListView {
				ItemsSource = MenuItems,
				VerticalOptions = LayoutOptions.FillAndExpand,
				BackgroundColor = Color.Transparent,
				RowHeight = 48,
			};

			var cell = new DataTemplate(typeof(ImageCell));
			cell.SetBinding(TextCell.TextProperty, "Title");
			cell.SetBinding(ImageCell.ImageSourceProperty, "Icon");
			cell.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent);

			Menu.ItemTemplate = cell;

			layout.Children.Add(Menu);

			this.Content = layout;
		}
开发者ID:rmawani,项目名称:DNA.XForms,代码行数:37,代码来源:MenuPage.cs

示例9: ForecastPage

        public ForecastPage(RootPage rootPage, Forecast forecast)
        {
            this._rootPage = rootPage;
            _forecast = forecast;
            BindingContext = new ForecastViewModel (Navigation, _forecast);

            NavigationPage.SetHasNavigationBar (this, false);

            var masterGrid = new Grid {
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition{ Height = new GridLength (0.3, GridUnitType.Star) },
                    new RowDefinition{ Height = new GridLength (0.3, GridUnitType.Star) },
                    new RowDefinition{ Height = new GridLength (0.4, GridUnitType.Star) }
                },
                ColumnDefinitions = new ColumnDefinitionCollection{ new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) } }
            };

            var forecastListview = new ListView ();

            var forecastListviewItemTemplate = new DataTemplate (typeof(ImageCell));

            forecastListviewItemTemplate.SetBinding (ImageCell.TextProperty, "ItemTemplateTextProperty");
              		forecastListviewItemTemplate.SetValue(ImageCell.TextColorProperty, Color.FromHex("#3498DB"));
            forecastListviewItemTemplate.SetBinding (ImageCell.DetailProperty, "ItemTemplateDetailProperty");
              		forecastListviewItemTemplate.SetValue(ImageCell.DetailColorProperty, Color.White);
            forecastListviewItemTemplate.SetBinding (ImageCell.ImageSourceProperty, "Icon");

            forecastListview.ItemTemplate = forecastListviewItemTemplate;
            forecastListview.SetBinding<ForecastViewModel> (ListView.ItemsSourceProperty, vm => vm.GroupList);

            var refreshImage = new ImageButton () {
                Image = "Refresh",
                ImageHeightRequest = 70,
                ImageWidthRequest = 70,
                BorderColor = Color.Transparent,
                VerticalOptions = LayoutOptions.Start,
                BackgroundColor = Color.Transparent
            };

            refreshImage.Clicked += (object sender, EventArgs e) => {
                /*_rootPage.ShowLoadingDialogAsync ();*/
            };

            var topGrid = new Grid {RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition{ Height = new GridLength (1, GridUnitType.Star) }
                },
                ColumnDefinitions = new ColumnDefinitionCollection {
                    new ColumnDefinition{ Width = new GridLength (0.8, GridUnitType.Star) },
                    new ColumnDefinition{ Width = new GridLength (0.2, GridUnitType.Star) },
                }
            };

            topGrid.Children.Add (CreateForecastStatusStackLayout (), 0, 0);
            topGrid.Children.Add (refreshImage, 1, 0);

            masterGrid.Children.Add (topGrid, 0, 0);
            masterGrid.Children.Add (CreateMiddleStackLayout (), 0, 1);
            masterGrid.Children.Add (forecastListview, 0, 2);

            Content = masterGrid;
        }
开发者ID:jsbuck,项目名称:Groupster,代码行数:61,代码来源:ForecastPage.cs

示例10: FolderSelectionPage

		public FolderSelectionPage(string path, Action updateAction, Color textColor, Color backgroundColor) : base()
		{
			this.path = path;
			this.updateAction = updateAction;

			Title = path;

			NavigationPage.SetTitleIcon(this, "HomeIcon.png");
			NavigationPage.SetBackButtonTitle(this, string.Empty);

			this.ToolbarItems.Add(new ToolbarItem(Catalog.GetString("New folder"), null, () =>
				{
					App.Click();
					var cfg = new PromptConfig();
					cfg.Message = Catalog.GetString("New folder name");
					cfg.Title = Catalog.GetString("New folder");
					cfg.OnResult = (result) =>
						{
							Device.BeginInvokeOnMainThread(() =>
								{
									App.Click();
									if (result.Ok)
									{
										Directory.CreateDirectory(Path.Combine(path, result.Text));
										this.path = Path.Combine(path, result.Text);
										UpdateDirectories();
									}
								});
						};
					UserDialogs.Instance.Prompt(cfg);
				}, ToolbarItemOrder.Secondary));

			var cell = new DataTemplate(typeof(TextCell));
			cell.SetValue(TextCell.TextColorProperty, textColor);
			cell.SetBinding(TextCell.TextProperty, "Name");

			list = new ListView() {
				BackgroundColor = backgroundColor,
				RowHeight = 50,
				HasUnevenRows = false,
				ItemTemplate = cell,
				ItemsSource = new PathItem[] {},
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
			};

			list.ItemTapped += (object sender, ItemTappedEventArgs e) => {
				var pathItem = ((PathItem)e.Item);
				this.path = pathItem.Path;

				Settings.Current.AddOrUpdateValue<string>(Settings.CartridgePathKey, this.path);

				if(updateAction != null)
				{
					updateAction();
				}

				UpdateDirectories();
			};

//			((StackLayout)ContentLayout).Children.Add(list);
			Content = list;

			UpdateDirectories();
		}
开发者ID:Surfoo,项目名称:WF.Player,代码行数:65,代码来源:FolderSelectionPage.cs

示例11: Init

        private async Task Init()
        {
            _itemSelectedEventHandler = (sender, args) =>
            {
                if (args.SelectedItem == null)
                    return;

                var listView = sender as ListView;
                var selectedItem = args.SelectedItem as DisasterViewModel;
                if (selectedItem != null)
                {
                    Navigation.PushAsync(new CommitmentPage(selectedItem.CommitmentData));
                }
                if (listView != null)
                {
                    listView.SelectedItem = null;
                }
            };

            BackgroundColor = Constants.HtBoxDarkBrown;

            // TODO: Implement a progress indicator
            ICrisisCheckInApiClient apiClient = new CrisisCheckInApiClient();
            var dtos = await apiClient.GetCommitmentsList(2); //TODO: wire up to Auth0 so we don't have to pass person ID
           // Data = dtos.Select(c => new DisasterViewModel(c));

            _disasterListView = new ListView
            {
                ItemsSource = Data,
                BackgroundColor = Constants.HtBoxDarkBrown
            };
            _disasterListView.ItemSelected += _itemSelectedEventHandler;
            var cell = new DataTemplate(typeof(TextCell));
            cell.SetBinding(TextCell.TextProperty, new Binding("DisasterName"));
            cell.SetBinding(TextCell.DetailProperty, new Binding("DisasterStatusAndDate"));
            cell.SetValue(TextCell.TextColorProperty, Color.White);
            cell.SetValue(TextCell.DetailColorProperty, Constants.HtBoxLightBrown);
            _disasterListView.ItemTemplate = cell;

            Content = _disasterListView;
        }
开发者ID:mjmilan,项目名称:crisischeckin,代码行数:41,代码来源:DisasterListPage.cs

示例12: CreateScheduleGrid

		private Grid CreateScheduleGrid ()
		{
			var scheduleGrid = new Grid {
				RowDefinitions = new RowDefinitionCollection {
					new RowDefinition {
						Height = new GridLength (1, GridUnitType.Star)
					}
				},
				ColumnDefinitions = new ColumnDefinitionCollection {
					new ColumnDefinition {
						Width = new GridLength (1, GridUnitType.Star)
					},
				},
				BackgroundColor = Color.White
			};

			var listview = new ListView {SeparatorVisibility = SeparatorVisibility.None};

			//Don't allow selection
			listview.ItemSelected += (sender, e) => {
				listview.SelectedItem = null;
			};

			var itemTemplate = new DataTemplate (typeof(ExtendedTextCell));

		    var cellPadding = new Thickness(40, 0, 0, 0);

            Device.OnPlatform(WinPhone:() =>
		    {
		        cellPadding = new Thickness(25,0,0,0);
		    });

			itemTemplate.SetValue (ExtendedTextCell.ThicknessProperty, cellPadding);
			itemTemplate.SetValue (ExtendedTextCell.LeftColumnWidthProperty, new GridLength (1.0, GridUnitType.Star));
			itemTemplate.SetBinding (ExtendedTextCell.LeftTextProperty, "Day");
			itemTemplate.SetValue (ExtendedTextCell.LeftTextColorProperty, Color.Black);
			itemTemplate.SetBinding (ExtendedTextCell.LeftDetailProperty, "HoursOfOperation");
			itemTemplate.SetValue (ExtendedTextCell.LeftDetailColorProperty, Color.Gray);

			listview.ItemTemplate = itemTemplate;
			listview.BindingContext = _extendedMap;
			listview.SetBinding<ExtendedMap> (ListView.ItemsSourceProperty, vm => vm.SelectedPin.ScheduleEntries);

			scheduleGrid.Children.Add (listview, 0, 0);

			return scheduleGrid;
		}
开发者ID:BradChase2011,项目名称:Xamarin.Forms.Plugins,代码行数:47,代码来源:FooterDetail.cs

示例13: CreateOtherView

		private View CreateOtherView ()
		{
			var contentView = new ContentView { BackgroundColor = Color.White };

			var listview = new ListView {SeparatorVisibility = SeparatorVisibility.None};

			//Don't allow selection
			listview.ItemSelected += (sender, e) => {
				listview.SelectedItem = null;
			};

			var itemTemplate = new DataTemplate (typeof(ExtendedTextCell));

			itemTemplate.SetValue (ExtendedTextCell.LeftColumnWidthProperty, new GridLength (0.85, GridUnitType.Star));
			itemTemplate.SetValue (ExtendedTextCell.RightColumnWidthProperty, new GridLength (0.15, GridUnitType.Star));
			itemTemplate.SetBinding (ExtendedTextCell.LeftTextProperty, "Key");
			itemTemplate.SetValue (ExtendedTextCell.LeftTextColorProperty, Color.Black);
			itemTemplate.SetBinding (ExtendedTextCell.LeftDetailProperty, "Value");
			itemTemplate.SetValue (ExtendedTextCell.LeftDetailColorProperty, Color.Gray);

			listview.ItemTemplate = itemTemplate;
			listview.BindingContext = _extendedMap;
			listview.SetBinding<ExtendedMap> (ListView.ItemsSourceProperty, vm => vm.SelectedPin.Others);


			contentView.Content = listview;

			return contentView;
		}
开发者ID:BradChase2011,项目名称:Xamarin.Forms.Plugins,代码行数:29,代码来源:FooterDetail.cs

示例14: SearchListTemplate


//.........这里部分代码省略.........
                    ? DateTime.Now.AddMonths(1).AddDays(-1)
                    : TimeConverter.DetermineTimeSettings(launchPair.Launch.Net, App.Settings.UseLocalTime),
                        LaunchNet = launchPair.Launch.Status == 2 || launchPair.Launch.Status == 0 && launchPair.Launch.Net.TimeOfDay.Ticks == 0
                        ? "TBD"
                        : TimeConverter.SetStringTimeFormat(launchPair.Launch.Net, App.Settings.UseLocalTime)
                    }).OrderBy(x => x.Net).ToList();

                    break;
                case OrderBy.Status:
                    var statusGoList = launchList.Where(x => LaunchStatusEnum.GetLaunchStatusById(x.Launch.Status) == LaunchStatus.Go).Select(launchPair => new SimpleLaunchData
                    {
                        LaunchId = launchPair.Launch.Id,
                        Name = launchPair.Launch.Name,
                        Net = launchPair.Launch.Status == 2
                    ? DateTime.Now.AddMonths(1).AddDays(-1)
                    : TimeConverter.DetermineTimeSettings(launchPair.Launch.Net, App.Settings.UseLocalTime),
                        LaunchNet = launchPair.Launch.Status == 2 || launchPair.Launch.Status == 0 && launchPair.Launch.Net.TimeOfDay.Ticks == 0
                        ? "TBD"
                        : TimeConverter.SetStringTimeFormat(launchPair.Launch.Net, App.Settings.UseLocalTime)
                    }).OrderBy(x => x.Net).ToList();

                    var statusHoldList = launchList.Where(x => LaunchStatusEnum.GetLaunchStatusById(x.Launch.Status) != LaunchStatus.Go).Select(launchPair => new SimpleLaunchData
                    {
                        LaunchId = launchPair.Launch.Id,
                        Name = launchPair.Launch.Name,
                        Net = launchPair.Launch.Status == 2
                            ? DateTime.Now.AddMonths(1).AddDays(-1)
                            : TimeConverter.DetermineTimeSettings(launchPair.Launch.Net, App.Settings.UseLocalTime),
                        LaunchNet = launchPair.Launch.Status == 2 || launchPair.Launch.Status == 0 && launchPair.Launch.Net.TimeOfDay.Ticks == 0
                        ? "TBD"
                        : TimeConverter.SetStringTimeFormat(launchPair.Launch.Net, App.Settings.UseLocalTime)
                    }).OrderBy(x => x.Net).ToList();

                    simpleLaunchList = statusGoList.Concat(statusHoldList);

                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(order), order, null);
            }

            ItemsSource = simpleLaunchList;
            VerticalOptions = LayoutOptions.FillAndExpand;
            BackgroundColor = Theme.BackgroundColor;
            SeparatorColor = Theme.FrameColor;
            HasUnevenRows = true;

            var menuDataTemplate = new DataTemplate(() =>
            {
                var nameLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    TextColor = Theme.TextColor,
                    FontSize = Device.OnPlatform(16, 20, 16),
                    FontAttributes = FontAttributes.Bold
                };
                var netLabel = new Label
                {
                    VerticalOptions = LayoutOptions.Center,
                    TextColor = Theme.TextColor,
                    FontSize = 14,
                };

                nameLabel.SetBinding(Label.TextProperty, "Name");
                netLabel.SetBinding(Label.TextProperty, "LaunchNet");

                var layout = new StackLayout
                {
                    Orientation = StackOrientation.Vertical,
                    VerticalOptions = LayoutOptions.Center,
                    Children =
                    {
                        nameLabel,
                        netLabel
                    }
                };

                var searchFrame = new MarginFrame(5, Theme.BackgroundColor)
                {
                    Content = new Frame
                    {
                        OutlineColor = Theme.FrameColor,
                        BackgroundColor = Theme.BackgroundColor,
                        VerticalOptions = LayoutOptions.Center,
                        Padding = new Thickness(5),
                        Content = layout,
                        Margin = new Thickness(0, 0, 12, 0),
                    }
                };

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

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

            ItemTemplate = menuDataTemplate;
            SelectedItem = launchList.Count != 0 ? launchList[0] : null;
            Margin = new Thickness(0, 0, 0, 30);
        }
开发者ID:threezool,项目名称:LaunchPal,代码行数:101,代码来源:SearchListTemplate.cs

示例15: ShareListPage

		public ShareListPage (Task task)
		{
			_task = task;
			_shares = new ObservableCollection<AADObject> ();

			#region UI Init

			this.Title = "tdlr;";
			NavigationPage.SetHasNavigationBar (this, false);

			_add = new Label {
				Text = "+",
				TextColor = Color.White,
				FontSize = 30,
				HorizontalOptions = LayoutOptions.End,
				VerticalOptions = LayoutOptions.Center,	
				IsVisible = true,
				Opacity = 1
			};

			_done = new Image {
				Aspect = Aspect.AspectFit,
				Source = ImageSource.FromFile ("ic_done_white.png"),
				HorizontalOptions = LayoutOptions.End,
				VerticalOptions = LayoutOptions.Center,
				IsVisible = true,
				Opacity = 1,
			};

			_unselect = new Image {
				Aspect = Aspect.AspectFit,
				Source = ImageSource.FromFile ("ic_done_white.png"),
				HorizontalOptions = LayoutOptions.End,
				VerticalOptions = LayoutOptions.Center,
				IsVisible = false,
				Opacity = 0,
			};

			Label vr = new Label {
				Text = "|",
				TextColor = Color.White,
				FontSize = 24,
				HorizontalOptions = LayoutOptions.End,
				VerticalOptions = LayoutOptions.Center,	
			};

			_delete = new Image {
				Aspect = Aspect.AspectFit,
				Source = ImageSource.FromFile("ic_delete.png"),
				HorizontalOptions = LayoutOptions.End,
				VerticalOptions = LayoutOptions.Center,
				IsVisible = false,
				Opacity = 0
			};

			Label header = new Label {
				Text = "Currently Shared With:",
				TextColor = Color.Black,
				FontSize = 18,
				FontFamily = "Montserrat-UltraLight",
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.Center,	
			};

			_shareList = new ListView {
				ItemsSource = _shares,
			};
			var cell = new DataTemplate(typeof(TextCell));
			cell.SetValue (TextCell.TextColorProperty, Color.Black);
			_shareList.ItemTemplate = cell;
			_shareList.ItemTemplate.SetBinding(TextCell.TextProperty, "displayName");

			Image menu = new Image {
				Aspect = Aspect.AspectFit,
				Source = ImageSource.FromFile ("ic_menu_white.png"),
				HorizontalOptions = LayoutOptions.Start,
				VerticalOptions = LayoutOptions.Center,
			};

			_navbar = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				HeightRequest = 50,
				Padding = new Thickness(10, 0, 20, 0),
				Spacing = 5,
				BackgroundColor = Color.Black,
				Children = {
					menu,
					new Label {
						Text = " tdlr;",
						HorizontalOptions = LayoutOptions.StartAndExpand,
						VerticalOptions = LayoutOptions.Center,
						FontFamily = "Pacifico",
						FontSize = 24,
						TextColor = Color.FromRgb(240,128,128)
					},
					_delete,
					_add,
					vr,
					_done,
					_unselect
//.........这里部分代码省略.........
开发者ID:skwan,项目名称:cloudroadshow-xamarin,代码行数:101,代码来源:ShareListPage.cs


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