internal void SetSource( DataGridControl dataGridControl, DataGridDetailDescription detailDescription )
      {
        if( ( dataGridControl == null ) || ( detailDescription == null ) || ( !dataGridControl.AreDetailsFlatten ) )
        {
          this.Source = null;
        }
        else
        {
          var map = this.Source as ItemPropertyNameMap;
          var itemProperties = detailDescription.ItemProperties;

          if( ( map == null ) || ( map.ItemProperties != detailDescription.ItemProperties ) )
          {
            this.Source = new ItemPropertyNameMap( itemProperties );
          }
        }
      }
      private void SynchronizeDetailSortDescriptions( SortDescriptionCollection masterSortDescriptions, SortDescriptionCollection detailSortDescriptions,
                                                      FieldNameMap itemPropertyMap )
      {
        ColumnSortCommand.ThrowIfNull( masterSortDescriptions, "masterSortDescriptions" );
        ColumnSortCommand.ThrowIfNull( detailSortDescriptions, "detailSortDescriptions" );
        ColumnSortCommand.ThrowIfNull( itemPropertyMap, "itemPropertyMap" );

        int masterSortDescriptionsCount = masterSortDescriptions.Count;
        if( masterSortDescriptionsCount > 0 )
        {
          int insertionIndex = 0;

          for( int i = 0; i < masterSortDescriptionsCount; i++ )
          {
            var sortDescription = masterSortDescriptions[ i ];

            string detailPropertyName;
            if( !itemPropertyMap.TryGetItemPropertyName( sortDescription.PropertyName, out detailPropertyName ) )
              continue;

            var detailDirection = sortDescription.Direction;

            if( insertionIndex < detailSortDescriptions.Count )
            {
              var detailSortDescription = detailSortDescriptions[ insertionIndex ];

              if( ( detailSortDescription.PropertyName != detailPropertyName ) || ( detailSortDescription.Direction != detailDirection ) )
              {
                detailSortDescriptions[ insertionIndex ] = new SortDescription( detailPropertyName, detailDirection );
              }
            }
            else
            {
              detailSortDescriptions.Add( new SortDescription( detailPropertyName, detailDirection ) );
            }

            insertionIndex++;
          }

          while( insertionIndex < detailSortDescriptions.Count )
          {
            detailSortDescriptions.RemoveAt( insertionIndex );
          }
        }
        else if( detailSortDescriptions.Count > 0 )
        {
          detailSortDescriptions.Clear();
        }
      }