Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,31 @@ internal void InternalTrimToSize()

#region Internal Properties

/// <summary>
/// Owner property.
/// </summary>
internal Grid Owner
{
get { return (_owner); }
set
{
if(_owner != null && _owner != value)
{
throw new ArgumentException(SR.Format(SR.GridCollection_InOtherCollection, "value", "ColumnDefinitionCollection"));
}
if(value == null)
{
return;
}
_owner = value;
for (int i = 0; i < _size; i++)
{
_owner.AddLogicalChild(_items[i]);
_items[i].OnEnterParentTree();
}
}
}

/// <summary>
/// Internal version of Count.
/// </summary>
Expand Down Expand Up @@ -742,7 +767,7 @@ private void PrivateSetCapacity(int value)
//------------------------------------------------------

#region Private Fields
private readonly Grid _owner; // owner of the collection
private Grid _owner; // owner of the collection
private DefinitionBase[] _items; // storage of items
private int _size; // size of the collection
private int _version; // version tracks updates in the collection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,16 @@ public ColumnDefinitionCollection ColumnDefinitions
}
set
{
_data ??= new ExtendedData();
_data.ColumnDefinitions ??= new ColumnDefinitionCollection(this);
_data.ColumnDefinitions.Clear();
if (value == null)
if (value?.Owner is not null)
{
return;
throw new ArgumentException(SR.Format(SR.GridCollection_InOtherCollection, "value", "ColumnDefinitionCollection"));
}
foreach (ColumnDefinition colDef in value)
_data ??= new ExtendedData();
_data.ColumnDefinitions?.Clear();
if (value is not null)
{
if (colDef.Parent != null)
{
throw new ArgumentException(SR.Format(SR.GridCollection_InOtherCollection, "value", "ColumnDefinitionCollection"));
}
colDef.Index = -1;
_data.ColumnDefinitions.Add(colDef);
value.Owner = this;
_data.ColumnDefinitions = value;
}
}
}
Expand Down