当前位置: 首页>>代码示例>>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;未经允许,请勿转载。