當前位置: 首頁>>代碼示例>>C#>>正文


C# DataTemplate.CreateContent方法代碼示例

本文整理匯總了C#中Xamarin.Forms.DataTemplate.CreateContent方法的典型用法代碼示例。如果您正苦於以下問題:C# DataTemplate.CreateContent方法的具體用法?C# DataTemplate.CreateContent怎麽用?C# DataTemplate.CreateContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Xamarin.Forms.DataTemplate的用法示例。


在下文中一共展示了DataTemplate.CreateContent方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RecycleCell

 public void RecycleCell(object data, DataTemplate dataTemplate, VisualElement parent)
 {
     if (_viewCell == null) {
         _viewCell = (dataTemplate.CreateContent () as FastGridCell);
         _viewCell.BindingContext = data;
         _viewCell.Parent = parent;
         _viewCell.PrepareCell (new Size (Bounds.Width, Bounds.Height));
         _originalBindingContext = _viewCell.BindingContext;
         var renderer = RendererFactory.GetRenderer (_viewCell.View);
         _view = renderer.NativeView;
         _view.AutoresizingMask = UIViewAutoresizing.All;
         _view.ContentMode = UIViewContentMode.ScaleToFill;
         ContentView.AddSubview (_view);
         return;
     } else if (data == _originalBindingContext) {
         _viewCell.BindingContext = _originalBindingContext;
     } else {
         _viewCell.BindingContext = data;
     }
 }
開發者ID:jwChung,項目名稱:TwinTechsFormsLib,代碼行數:20,代碼來源:GridViewCell.cs

示例2: SetupContentGrid

        private void SetupContentGrid()
        {
            _contentGrid = new Grid {
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                RowDefinitions = {
                    new RowDefinition { Height = Device.OnPlatform(32,10,0) },
                    new RowDefinition { Height = 50 },
                    new RowDefinition { Height = Device.OnPlatform(200,220,0) },
                    new RowDefinition { Height = 50 },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = 40 },
                },
                IsVisible = false
            };

            _contentGrid.Children.Add(new StackLayout { Padding = new Thickness(20, 0, 0, 0), Children = { new Label { Text = "Upcoming Events", TextColor = Color.White, FontSize = 24, VerticalOptions = LayoutOptions.CenterAndExpand } } }, 0, 1);
            _contentGrid.Children.Add(new StackLayout { Padding = new Thickness(20, 0, 0, 0), Children = { new Label { Text = "Recent Messages", TextColor = Color.White, FontSize = 24, VerticalOptions = LayoutOptions.CenterAndExpand } } }, 0, 3);

            _calendarEventListView = new NoHighlightListView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, BackgroundColor = Color.Transparent };
            var calendarEventItemTemplate = new DataTemplate(() => new CalendarEventItemTemplate());
            calendarEventItemTemplate.CreateContent();
            _calendarEventListView.SeparatorVisibility = SeparatorVisibility.None;
            _calendarEventListView.ItemsSource = _calendarEvents;
            _calendarEventListView.ItemTemplate = calendarEventItemTemplate;
            _calendarEventListView.HasUnevenRows = true;
            _calendarEventListView.ItemTapped += (sender, e) => {
                if (e.Item == null) {
                    return;
                }
                ((ListView)sender).SelectedItem = null;
            };
            _contentGrid.Children.Add(_calendarEventListView, 0, 2);

            _messageListView = new NoHighlightListView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, BackgroundColor = Color.Transparent };
            var messageItemTemplate = new DataTemplate(() => new MessageItemTemplate());
            messageItemTemplate.CreateContent();
            _messageListView.SeparatorVisibility = SeparatorVisibility.None;
            _messageListView.ItemsSource = _messages;
            _messageListView.ItemTemplate = messageItemTemplate;
            _messageListView.HasUnevenRows = true;
            _messageListView.ItemTapped += (sender, e) => {
                if (e.Item == null) {
                    return;
                }
                ((ListView)sender).SelectedItem = null;
            };
            _contentGrid.Children.Add(_messageListView, 0, 4);

            Button refreshButton = new Button { Text = "Refresh", TextColor = Color.White, FontSize = 18, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.EndAndExpand, BackgroundColor = Color.Transparent };
            refreshButton.Clicked += RefreshButton_Clicked;
            _contentGrid.Children.Add(new StackLayout { Orientation = StackOrientation.Horizontal, Children = { refreshButton }, Padding = new Thickness(0,0,10,0) }, 0, 5);

            _backgroundGrid.Children.Add(_contentGrid, 0, 0);
        }
開發者ID:rringham,項目名稱:XamarinOffice365,代碼行數:55,代碼來源:Office365DashboardPage.cs


注:本文中的Xamarin.Forms.DataTemplate.CreateContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。