コード例 #1
0
        private static ItemsRepeaterScrollHost CreateAndInitializeRepeater(
            object itemsSource,
            VirtualizingLayout layout,
            ElementFactory elementFactory,
            ref ItemsRepeater repeater,
            ref ScrollViewer scrollViewer)
        {
            repeater = new ItemsRepeater()
            {
                ItemsSource         = itemsSource,
                Layout              = layout,
                ItemTemplate        = elementFactory,
                VerticalCacheLength = 0
            };

            scrollViewer = new ScrollViewer()
            {
                Content = repeater
            };

            return(new ItemsRepeaterScrollHost()
            {
                Width = 400,
                Height = 400,
                ScrollViewer = scrollViewer
            });
        }
コード例 #2
0
        private ItemsRepeaterScrollHost CreateAndInitializeRepeater(
            object itemsSource,
            VirtualizingLayout layout,
            object elementFactory,
            ref ItemsRepeater repeater,
            ref ScrollViewer scrollViewer)
        {
            repeater = new ItemsRepeater()
            {
                ItemsSource = itemsSource,
                Layout      = layout,
#if BUILD_WINDOWS
                ItemTemplate = (Windows.UI.Xaml.IElementFactory)elementFactory,
#else
                ItemTemplate = elementFactory,
#endif
                HorizontalCacheLength = 0,
                VerticalCacheLength   = 0,
            };

            scrollViewer = new ScrollViewer()
            {
                Content = repeater
            };

            return(new ItemsRepeaterScrollHost()
            {
                Width = 400,
                Height = 400,
                ScrollViewer = scrollViewer
            });
        }
コード例 #3
0
 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");
     }
 }
コード例 #4
0
        private static ScrollAnchorProvider CreateAndInitializeRepeater(
            object itemsSource,
            VirtualizingLayout layout,
            ElementFactory elementFactory,
            ref ItemsRepeater repeater,
            ref ScrollViewer scrollViewer)
        {
            repeater = new ItemsRepeater()
            {
                ItemsSource = itemsSource,
                Layout      = layout,
#if BUILD_WINDOWS
                ItemTemplate = (Windows.UI.Xaml.IElementFactory)elementFactory,
#else
                ItemTemplate = elementFactory,
#endif
                VerticalCacheLength = 0
            };

            scrollViewer = new ScrollViewer()
            {
                Content = repeater
            };

            return(new ScrollAnchorProvider()
            {
                Width = 400,
                Height = 400,
                Content = scrollViewer
            });
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        private VirtualizingLayout GetStackLayout()
        {
            if (_stackLayout == null)
            {
                _stackLayout = new StackLayout()
                {
                    Spacing     = double.Parse(lineSpacing.Text),
                    Orientation = orientation.IsOn ? Orientation.Horizontal : Orientation.Vertical,
                };
            }

            return(_stackLayout);
        }
コード例 #7
0
        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), lineAlignment.Text),
                    Orientation      = orientation.IsOn ? Orientation.Vertical : Orientation.Horizontal,
                };
            }

            return(_flowLayout);
        }
コード例 #8
0
        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), lineAlignment.Text),
                    Orientation        = orientation.IsOn ?  Orientation.Vertical: Orientation.Horizontal,
                };
            }

            return(_gridLayout);
        }
コード例 #9
0
        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.Load(
                    @"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'> " + itemContent + @"</DataTemplate>");

                repeater = new ItemsRepeater()
                {
                    ItemsSource = dataSource,
#if BUILD_WINDOWS
                    ItemTemplate = (Windows.UI.Xaml.IElementFactory)elementFactory,
#else
                    ItemTemplate = elementFactory,
#endif
                    Layout = layout,
                    HorizontalCacheLength = 0.0,
                    VerticalCacheLength   = 0.0
                };

                sv = new ScrollViewer
                {
                    Content = repeater
                };

                Content = new ScrollAnchorProvider()
                {
                    Width   = 200,
                    Height  = 200,
                    Content = sv
                };
            });

            IdleSynchronizer.Wait();
            scrollViewer = sv;
            return(repeater);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        private ItemsRepeater SetupRepeater(CustomItemsSource dataSource, ElementFactory elementFactory, ref ScrollViewer scrollViewer, VirtualizingLayout layout)
        {
            var repeater = new ItemsRepeater()
            {
                ItemsSource = dataSource,
#if BUILD_WINDOWS
                ItemTemplate = (Windows.UI.Xaml.IElementFactory)elementFactory,
#else
                ItemTemplate = elementFactory,
#endif
                Layout = layout,
                VerticalCacheLength   = 0,
                HorizontalCacheLength = 0
            };

            scrollViewer = new ScrollViewer
            {
                Content = repeater
            };

            Content = new ItemsRepeaterScrollHost()
            {
                Width        = 200,
                Height       = 200,
                ScrollViewer = scrollViewer
            };

            Content.UpdateLayout();
            int realized = VerifyRealizedRange(repeater, dataSource);

            Verify.IsGreaterThan(realized, 0);

            return(repeater);
        }
コード例 #12
0
        private ItemsRepeater SetupRepeater(CustomItemsSource dataSource, VirtualizingLayout layout)
        {
            ScrollViewer sv = null;

            return(SetupRepeater(dataSource, GetElementFactory(), ref sv, layout));
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 private ItemsRepeater SetupRepeater(object dataSource, VirtualizingLayout layout, out ScrollViewer scrollViewer)
 {
     return(SetupRepeater(dataSource, layout, @"<Button Content='{Binding}' Height='100' />", out scrollViewer));
 }
コード例 #15
0
        private ItemsRepeater CreateRepeater(object dataSource, object elementFactory, VirtualizingLayout layout = null)
        {
            var repeater = new ItemsRepeater
            {
                ItemsSource = dataSource,
#if BUILD_WINDOWS
                ItemTemplate = (Windows.UI.Xaml.IElementFactory)elementFactory,
#else
                ItemTemplate = elementFactory,
#endif
            };

            repeater.Layout = layout ?? CreateLayout(repeater);
            return(repeater);
        }