コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RowDefinitionCollection"/> class.
        /// </summary>
        /// <param name="grid">The <see cref="Grid"/> that owns the collection.</param>
        internal RowDefinitionCollection(Grid grid)
        {
            Contract.Require(grid, nameof(grid));

            this.grid        = grid;
            this.implicitRow = new RowDefinition() { Grid = grid, Height = new GridLength(1, GridUnitType.Star) };
            this.implicitStorage.Add(implicitRow);
        }
コード例 #2
0
        /// <summary>
        /// Gets a value indicating whether the collection contains the specified row.
        /// </summary>
        /// <param name="definition">The row to evaluate.</param>
        /// <returns><c>true</c> if the collection contains the specified row; otherwise, <c>false</c>.</returns>
        public Boolean Contains(RowDefinition definition)
        {
            Contract.Require(definition, "definition");

            if (storage.Count == 0)
            {
                return definition == implicitRow;
            }
            return storage.Contains(definition);
        }
コード例 #3
0
        /// <summary>
        /// Adds a row to the collection.
        /// </summary>
        /// <param name="definition">The row definition to add to the collection.</param>
        public void Add(RowDefinition definition)
        {
            Contract.Require(definition, "definition");

            if (definition.Grid != null)
                definition.Grid.RowDefinitions.Remove(definition);

            definition.Grid = grid;
            storage.Add(definition);

            OnModified();
        }
コード例 #4
0
        /// <summary>
        /// Removes a row from the collection.
        /// </summary>
        /// <param name="definition">The row to remove from the collection.</param>
        /// <returns><c>true</c> if the specified row was removed from the collection; otherwise, <c>false</c>.</returns>
        public Boolean Remove(RowDefinition definition)
        {
            Contract.Require(definition, "definition");

            if (storage.Remove(definition))
            {
                definition.Grid = null;

                OnModified();
                return true;
            }
            return false;
        }