Esempio n. 1
0
        private static void OnItemsSourceChanged(AutoGrid grid, object?oldValue, object?newValue)
        {
            var sequence = newValue as IEnumerable <object> ?? newValue.To().Enumerable();

            grid.Children.Clear();
            sequence.BindTo(grid.Children.WrapAsTypedList(), (o, e) => o == e || o == (e as ContentPresenter)?.Content, x =>
            {
                var element = x as UIElement ?? CreateContentPresenter(x, grid);
                if (element != null)
                {
                    element.Visibility = Visibility.Collapsed;
                }
                return(element);
            }, e => e != null, null, grid.InvalidateChildren);
        }
Esempio n. 2
0
        private static UIElement?CreateContentPresenter(object?data, AutoGrid container)
        {
            var element = (FrameworkElement)Selector.SelectTemplate(data, container)?.LoadContent();// new ResourceContentPresenter{Content = data};

            if (element is ContentPresenter x)
            {
                x.Content = data;
            }
            else if (element is ContentControl y)
            {
                y.Content = data;
            }
            else if (element != null)
            {
                element.DataContext = data;
            }


            return(element);
        }
Esempio n. 3
0
 private static void OnDefaultSizeChanged(AutoGrid grid, string oldValue, string newValue)
 {
     grid.DefaultGridLength = newValue == null ? default(GridLength?) : grid.CreateGridLength(newValue);
     //grid.InvalidateChildren();
 }
Esempio n. 4
0
 private static void OnColumnOrRowSizesChanged(AutoGrid grid, string oldValue, string newValue)
 {
     //grid.InvalidateChildren();
 }