示例#1
0
        internal object CreateDomElement_CSSVersion(object parentRef, out object domElementWhereToPlaceChildren)
        {
#if !BRIDGE
            object outerDiv = base.CreateDomElement(parentRef, out _innerDiv);
#else
            object outerDiv = CreateDomElement_WorkaroundBridgeInheritanceBug(parentRef, out _innerDiv);
#endif
            domElementWhereToPlaceChildren = _innerDiv;

            // Set the element on which the "MaxWidth" and "MaxHeight" properties should be applied (cf. zendesk ticket #1178 where scrollbars inside the ChildWindow did not function properly):
            this.INTERNAL_OptionalSpecifyDomElementConcernedByMinMaxHeightAndWidth = _innerDiv;

            // Set the "display" CSS property:
            dynamic style = INTERNAL_HtmlDomManager.GetDomElementStyleForModification(_innerDiv);
            style.display = !Grid_InternalHelpers.isMSGrid() ? style.display = "grid" : Grid_InternalHelpers.INTERNAL_CSSGRID_MS_PREFIX + "grid";

            // Normalize the sizes of the rows and columns:
            List <ColumnDefinition> normalizedColumnDefinitions = null;
            List <RowDefinition>    normalizedRowDefinitions    = null;
            Grid_InternalHelpers.NormalizeWidthAndHeightPercentages(this, _columnDefinitionsOrNull, _rowDefinitionsOrNull, out normalizedColumnDefinitions, out normalizedRowDefinitions);

            // Refresh the rows heights and columns widths:
            Grid_InternalHelpers.RefreshAllRowsHeight_CSSVersion(this, normalizedColumnDefinitions, normalizedRowDefinitions);
            Grid_InternalHelpers.RefreshAllColumnsWidth_CSSVersion(this, normalizedColumnDefinitions, normalizedRowDefinitions);

            return(outerDiv);
        }
示例#2
0
        void ColumnDefinitions_CollectionChanged_CSSVersion(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (INTERNAL_VisualTreeManager.IsElementInVisualTree(this))
            {
                if (e.NewItems != null)
                {
                    //foreach (ColumnDefinition columnDefinition in e.NewItems)
                    //{
                    //    columnDefinition.Parent = this;
                    //    if (columnDefinition.Visibility == Visibility.Collapsed)
                    //    {
                    //        Grid_InternalHelpers.RefreshColumnVisibility(this, columnDefinition, Visibility.Collapsed);
                    //        //columnDefinition.Visibility = Visibility.Collapsed; //to call the Visibility_changed callback. //Note: this could set the localValue when it should be the VisualStateValue.
                    //    }
                    //}
                    Grid_InternalHelpers.RefreshAllColumnsWidth_CSSVersion(this);
                }

                if (this._isLoaded)
                {
                    Grid_InternalHelpers.RefreshAllColumnsWidth_CSSVersion(this);

                    LocallyManageChildrenChanged();
                }
            }
        }
示例#3
0
        private void ColumnDefinitions_CollectionChanged_CSSVersion(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (INTERNAL_VisualTreeManager.IsElementInVisualTree(this))
            {
                if (e.NewItems != null)
                {
                    Grid_InternalHelpers.RefreshAllColumnsWidth_CSSVersion(this);
                }

                if (this._isLoaded)
                {
                    Grid_InternalHelpers.RefreshAllColumnsWidth_CSSVersion(this);

                    LocallyManageChildrenChanged();
                }
            }
        }
示例#4
0
        private static void Width_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var columnDefinition = (ColumnDefinition)d;

            Grid grid = columnDefinition.Parent;

            if (grid != null &&
                INTERNAL_VisualTreeManager.IsElementInVisualTree(grid))
            {
                if (Grid_InternalHelpers.isCSSGridSupported())
                {
                    //-------------
                    // CSS Grid
                    //-------------

                    // We refresh all the columns:
                    Grid_InternalHelpers.RefreshAllColumnsWidth_CSSVersion(grid);
                }
                else
                {
                    //-------------
                    // Non-CSS Grid
                    //-------------

                    bool isStar = (e.OldValue != null && ((GridLength)e.OldValue).IsStar) || (e.NewValue != null && ((GridLength)e.NewValue).IsStar);
                    if (isStar)
                    {
                        // If we are dealing with a "Star" column, we need to refresh all the columns (because of the need to recalculate percentages normalization etc.):
                        Grid_InternalHelpers.RefreshAllColumnsWidth_NonCSSVersion(grid);
                    }
                    else
                    {
                        // Only refresh the current column:
                        if (grid._columnDefinitionsOrNull != null)
                        {
                            int  columnIndex     = grid._columnDefinitionsOrNull.IndexOf(columnDefinition);
                            bool isTheOnlyColumn = grid._columnDefinitionsOrNull == null || grid._columnDefinitionsOrNull.Count < 2;
                            Grid_InternalHelpers.RefreshColumnWidth_NonCSSVersion(grid, columnIndex, isTheOnlyColumn); //Note: we do not need to pass the normalized column definition because this method will only be called when we change the column's width without any star measurement involved (nor star before nor after).
                        }
                    }
                }
            }

            columnDefinition.Parent?.InvalidateMeasure();
        }