Beispiel #1
0
        private static void ItemsChanged(AvaloniaPropertyChangedEventArgs e)
        {
            var grid     = (SimpleGrid)e.Sender;
            var items    = (IEnumerable)e.NewValue;
            var template = grid.GetValue(TemplateProperty);

            grid.Children.Clear();

            if (items != null)
            {
                int count = 0;
                int cols  = 3;

                foreach (var item in items)
                {
                    foreach (var control in template(item))
                    {
                        grid.Children.Add(control);
                        SimpleGrid.SetColumn(control, count % cols);
                        SimpleGrid.SetRow(control, count / cols);
                        ++count;
                    }
                }
            }
        }
Beispiel #2
0
        private void InitializeComponent()
        {
            Func<object, IEnumerable<Control>> pt = PropertyTemplate;

            Content = new ScrollViewer
            {
                Content = _grid = new SimpleGrid
                {
                    [GridRepeater.TemplateProperty] = pt,
                }
            };
        }
Beispiel #3
0
        private void InitializeComponent()
        {
            Func <object, IEnumerable <Control> > pt = PropertyTemplate;

            Content = new ScrollViewer
            {
                Content = _grid = new SimpleGrid
                {
                    Styles =
                    {
                        new Style(x => x.Is <Control>())
                        {
                            Setters = new[]
                            {
                                new Setter(MarginProperty, new Thickness(2)),
                            }
                        },
                    },
                    [GridRepeater.TemplateProperty] = pt,
                }
            };
        }