Ejemplo 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);
        }
Ejemplo 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);
        }
Ejemplo n.º 3
0
 private static void OnDefaultSizeChanged(AutoGrid grid, string oldValue, string newValue)
 {
     grid.DefaultGridLength = newValue == null ? default(GridLength?) : grid.CreateGridLength(newValue);
     //grid.InvalidateChildren();
 }
Ejemplo n.º 4
0
 private static void OnColumnOrRowSizesChanged(AutoGrid grid, string oldValue, string newValue)
 {
     //grid.InvalidateChildren();
 }