private ItemsRepeaterScrollHost CreateAndInitializeRepeater( object itemsSource, VirtualizingLayout layout, object elementFactory, ref ItemsRepeater repeater, ref ScrollViewer scrollViewer) { repeater = new ItemsRepeater() { ItemsSource = itemsSource, Layout = layout, ItemTemplate = elementFactory, HorizontalCacheLength = 0, VerticalCacheLength = 0, }; scrollViewer = new ScrollViewer() { Content = repeater }; return(new ItemsRepeaterScrollHost() { Width = 400, Height = 400, ScrollViewer = scrollViewer }); }
public static void SetOrientation(this VirtualizingLayout layout, ScrollOrientation scrollOrientation) { // Note: // The public properties of UniformGridLayout and FlowLayout interpret orientation the opposite to // how FlowLayoutAlgorithm interprets it. // For simplicity, all of our test validation code is written in terms that match the implementation. // For this reason, we need to switch the orientation whenever we set UniformGridLayout.Orientation // or StackLayout.Orientation. if (layout is StackLayout) { ((StackLayout)layout).Orientation = scrollOrientation.ToLayoutOrientation(); } else if (layout is UniformGridLayout) { ((UniformGridLayout)layout).Orientation = scrollOrientation.ToOrthogonalLayoutOrientation(); } else if (layout is FlowLayout) { ((FlowLayout)layout).Orientation = scrollOrientation.ToOrthogonalLayoutOrientation(); } else { throw new InvalidOperationException("layout unknown"); } }
private ItemsRepeater SetupRepeater(object dataSource, string itemContent = @"<Button Content='{Binding}' Height='100' />") { VirtualizingLayout layout = null; RunOnUIThread.Execute(() => layout = new StackLayout()); ScrollViewer scrollViewer = null; return(SetupRepeater(dataSource, layout, itemContent, out scrollViewer)); }
private VirtualizingLayout GetStackLayout() { if (_stackLayout == null) { _stackLayout = new StackLayout() { Spacing = double.Parse(lineSpacing.Text), Orientation = orientation.IsOn ? Orientation.Horizontal : Orientation.Vertical, }; } return(_stackLayout); }
private VirtualizingLayout GetFlowLayout() { if (_flowLayout == null) { _flowLayout = new FlowLayout() { MinRowSpacing = double.Parse(itemSpacing.Text), MinColumnSpacing = double.Parse(lineSpacing.Text), LineAlignment = (FlowLayoutLineAlignment)Enum.Parse(typeof(FlowLayoutLineAlignment), lineAlingment.Text), Orientation = orientation.IsOn ? Orientation.Vertical : Orientation.Horizontal, }; } return(_flowLayout); }
private VirtualizingLayout GetGridLayout() { if (_gridLayout == null) { _gridLayout = new UniformGridLayout() { MinItemWidth = 150, MinItemHeight = 150, MinRowSpacing = double.Parse(itemSpacing.Text), MinColumnSpacing = double.Parse(lineSpacing.Text), ItemsJustification = (UniformGridLayoutItemsJustification)Enum.Parse(typeof(UniformGridLayoutItemsJustification), lineAlingment.Text), Orientation = orientation.IsOn ? Orientation.Vertical : Orientation.Horizontal, }; } return(_gridLayout); }
private ItemsRepeater SetupRepeater(object dataSource, VirtualizingLayout layout, string itemContent, out ScrollViewer scrollViewer) { ItemsRepeater repeater = null; ScrollViewer sv = null; RunOnUIThread.Execute(() => { var elementFactory = new RecyclingElementFactory(); elementFactory.RecyclePool = new RecyclePool(); elementFactory.Templates["Item"] = (DataTemplate)XamlReader.Parse( @"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> " + itemContent + @"</DataTemplate>"); repeater = new ItemsRepeater() { ItemsSource = dataSource, ItemTemplate = elementFactory, Layout = layout, HorizontalCacheLength = 0.0, VerticalCacheLength = 0.0 }; sv = new ScrollViewer { Content = repeater }; Content = new ItemsRepeaterScrollHost() { Width = 200, Height = 200, ScrollViewer = sv }; }); IdleSynchronizer.Wait(); scrollViewer = sv; return(repeater); }
private ItemsRepeater SetupRepeater(CustomItemsSource dataSource, ElementFactory elementFactory, ref ScrollViewer scrollViewer, VirtualizingLayout layout) { var repeater = new ItemsRepeater() { ItemsSource = dataSource, ItemTemplate = elementFactory, Layout = layout, VerticalCacheLength = 0, HorizontalCacheLength = 0 }; scrollViewer = new ScrollViewer { Content = repeater }; Content = new ItemsRepeaterScrollHost() { Width = 200, Height = 200, ScrollViewer = scrollViewer }; Content.UpdateLayout(); if (dataSource.Count > 0) { int realized = VerifyRealizedRange(repeater, dataSource); Verify.IsGreaterThan(realized, 0); } return(repeater); }
private ItemsRepeater SetupRepeater(CustomItemsSource dataSource, VirtualizingLayout layout) { ScrollViewer sv = null; return(SetupRepeater(dataSource, GetElementFactory(), ref sv, layout)); }
private ItemsRepeater CreateRepeater(object dataSource, object elementFactory, VirtualizingLayout layout = null) { var repeater = new ItemsRepeater { ItemsSource = dataSource, ItemTemplate = elementFactory, }; repeater.Layout = layout ?? CreateLayout(repeater); return(repeater); }
private ItemsRepeater SetupRepeater(object dataSource, VirtualizingLayout layout, out ScrollViewer scrollViewer) { return(SetupRepeater(dataSource, layout, @"<Button Content='{Binding}' Height='100' />", out scrollViewer)); }