public int GetGroupIndex( Group group )
    {
      if( group == null )
        throw new ArgumentNullException( "group" );

      this.EnsureNodeTreeCreated();

      GeneratorNodeHelper nodeHelper = new GeneratorNodeHelper( m_startNode, 0, 0 );

      if( nodeHelper.FindGroup( group.CollectionViewGroup ) )
        return nodeHelper.Index;

      //the item was not found in this generator's content... check all the detail generators
      foreach( KeyValuePair<object, List<DetailGeneratorNode>> itemToDetails in m_masterToDetails )
      {
        foreach( DetailGeneratorNode detailNode in itemToDetails.Value )
        {
          int groupIndex = detailNode.DetailGenerator.GetGroupIndex( group );

          if( groupIndex > -1 )
            return groupIndex + this.FindGlobalIndexForDetailNode( detailNode );
        }
      }

      return -1;
    }
    public Group GetGroupFromCollectionViewGroup( Group parentUIGroup, CollectionViewGroup collectionViewGroup )
    {
      this.EnsureNodeTreeCreated();
      GroupGeneratorNode groupGeneratorNode = null;

      if( m_groupNodeMappingCache.TryGetValue( collectionViewGroup, out groupGeneratorNode ) )
        return groupGeneratorNode.UIGroup;

      return null;
    }
示例#3
0
    internal void SetGroup( Group group )
    {
      m_group = group;
      this.Content = m_group;
      GroupHeaderControl.SetGroup( this, group );

      if( this.PropertyChanged != null )
      {
        this.PropertyChanged( this, new PropertyChangedEventArgs( "Group" ) );
      }
    }
示例#4
0
 internal static void SetGroup( DependencyObject obj, Group value )
 {
   obj.SetValue( GroupHeaderControl.GroupProperty, value );
 }
    private void UpdateContentTemplate( Column column, Group group )
    {
      if( column == null )
        return;

      bool contentTemplateAffected = false;
      bool contentTemplateSelectorAffected = false;

      if( column.GroupValueTemplate != null )
      {
        this.ContentTemplate = column.GroupValueTemplate;
        contentTemplateAffected = true;
      }
      else if( column.GroupValueTemplateSelector != null )
      {
        this.ContentTemplateSelector = column.GroupValueTemplateSelector;
        contentTemplateSelectorAffected = true;
      }

      if( !contentTemplateAffected && !contentTemplateSelectorAffected )
      {
        ForeignKeyConfiguration foreignKeyConfiguration = column.ForeignKeyConfiguration;
        if( foreignKeyConfiguration != null )
        {
          if( column.CellContentTemplate != null )
          {
            this.ContentTemplate = column.CellContentTemplate;
            contentTemplateAffected = true;
          }
          else if( column.CellContentTemplateSelector != null )
          {
            this.ContentTemplateSelector = column.CellContentTemplateSelector;
            contentTemplateSelectorAffected = true;
          }
        }
      }

      if( !contentTemplateAffected )
      {
        this.ClearValue( ContentPresenter.ContentTemplateProperty );
      }

      if( !contentTemplateSelectorAffected )
      {
        this.ClearValue( ContentPresenter.ContentTemplateSelectorProperty );
      }
    }
    private void UpdateContent( Group group )
    {
      DataGridContext dataGridContext = DataGridControl.GetDataGridContext( this );

      if( dataGridContext == null )
        return;

      if( group == null )
        return;

      string groupBy = group.GroupBy;

      if( string.IsNullOrEmpty( groupBy ) )
        throw new DataGridInternalException( "Group.GroupBy is null." );

      Column column = dataGridContext.Columns[ groupBy ] as Column;

      object newContent = group.Value;

      if( column != null )
      {
        ForeignKeyConfiguration foreignKeyConfiguration = column.ForeignKeyConfiguration;

        if( foreignKeyConfiguration != null )
        {
          // Ensure to set the Content converted according to the DataContext
          // when a converter is present. Else, the DataContext will be displayed
          if( foreignKeyConfiguration.ForeignKeyConverter != null )
          {
            newContent = foreignKeyConfiguration.ForeignKeyConverter.GetValueFromKey(
                                                                        group.Value,
                                                                        foreignKeyConfiguration );
          }
        }
      }

      // We must update the template according
      // to values present on Column
      this.UpdateContentTemplate( column, group );

      this.Content = newContent;
    }
    internal void SetGroup( Group group )
    {
      m_group = group;
      this.Content = m_group;
      GroupHeaderControl.SetGroup( this, group );

      this.RaisePropertyChanged( "Group" );
    }