protected override UIElement GetElementCore(ElementFactoryGetArgs args) { var element = (FrameworkElement)_personTemplate.LoadContent(); element.DataContext = args.Data; return(element); }
protected override UIElement GetElementCore(ElementFactoryGetArgs args) #endif { var key = (args.Data is RecipeGroup) ? "Group" : "Recipe"; var element = (FrameworkElement)_recyclePool.TryGetElement(key, args.Parent); if (element == null) { if (args.Data is RecipeGroup) { element = (FrameworkElement)_groupTemplate.LoadContent(); _innerRepeaters.Add((ItemsRepeater)element.FindName("groupLayout")); } else { element = (FrameworkElement)_recipeTemplate.LoadContent(); } } element.Tag = key; if (args.Data is RecipeGroup) { var group = (RecipeGroup)args.Data; var groupName = (TextBlock)element.FindName("groupName"); var repeater = (ItemsRepeater)element.FindName("groupLayout"); groupName.Text = group.Name; var dataSource = new DelegatingItemsSource(group); dataSource.KeyFromIndexFunc = _KeyFromIndexFunc; repeater.ItemsSource = dataSource; repeater.Layout = IsInnerLayoutGrid ? (VirtualizingLayout) new UniformGridLayout() { MinItemWidth = 150, MinItemHeight = 150 } : (VirtualizingLayout) new StackLayout(); RepeaterTestHooks.SetLayoutId(repeater.Layout, group.Name); repeater.ItemTemplate = this; repeater.Animator = _animator; } else { var recipe = (Recipe)args.Data; var image = (Image)element.FindName("recipeImage"); var description = (TextBlock)element.FindName("recipeDescription"); image.Source = new BitmapImage(recipe.ImageUri); description.Text = recipe.Description; } return(element); }
protected override UIElement GetElementCore(ElementFactoryGetArgs args) { var data = args.Data; string key = GetContainerType(data); var element = RecyclePool.TryGetElement(key, args.Parent); element = element ?? (FrameworkElement)CreateContainer(key); if (element == null) { throw new InvalidOperationException("Unable to create a container for key " + key); } PrepareContainer(element, key, data); (element as FrameworkElement).Tag = key; return(element); }
public UIElement GetElement(ElementFactoryGetArgs args)