当前位置: 首页>>代码示例>>C#>>正文


C# DataGridContext.GetBindingPathExtractorForColumn方法代码示例

本文整理汇总了C#中DataGridContext.GetBindingPathExtractorForColumn方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridContext.GetBindingPathExtractorForColumn方法的具体用法?C# DataGridContext.GetBindingPathExtractorForColumn怎么用?C# DataGridContext.GetBindingPathExtractorForColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataGridContext的用法示例。


在下文中一共展示了DataGridContext.GetBindingPathExtractorForColumn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExportDataItemCore

      private void ExportDataItemCore( DataGridContext dataGridContext, ClipboardExporterBase clipboardExporter, int itemIndex, object item, int[] exportedVisiblePositions,
                                       ColumnBase[] columnsByVisiblePosition )
      {
        DataGridCollectionViewBase dataGridCollectionViewBase = dataGridContext.ItemsSourceCollection as DataGridCollectionViewBase;

        clipboardExporter.StartDataItem( dataGridContext, item );

        // Ensure the count does not exceeds the columns count
        int exportedVisiblePositionsCount = exportedVisiblePositions.Length;
        exportedVisiblePositionsCount = Math.Min( exportedVisiblePositionsCount, columnsByVisiblePosition.Length );

        HashSet<int> intersectedIndexes = this.GetIntersectedRangesForIndex( dataGridContext, itemIndex, exportedVisiblePositions, exportedVisiblePositionsCount );

        object fieldValue = null;
        Column column = null;

        for( int i = 0; i < exportedVisiblePositionsCount; i++ )
        {
          // Reset field value
          fieldValue = null;

          int visiblePosition = exportedVisiblePositions[ i ];

          // Export null if not intersected by a SelectionRange
          if( intersectedIndexes.Contains( visiblePosition ) )
          {
            // Only export visible data column
            column = columnsByVisiblePosition[ visiblePosition ] as Column;

            if( column == null )
              continue;

            // Use DataGridCollectionView directly since the DataGridItemProperty uses PropertyDescriptor which increase
            // the read of the field value
            DataGridItemPropertyBase dataGridItemProperty = null;

            // Try to get a DataGridItemProperty matching the column FieldName
            // and get the value from it
            if( dataGridCollectionViewBase != null )
            {
              dataGridItemProperty = dataGridCollectionViewBase.ItemProperties[ column.FieldName ];

              if( dataGridItemProperty != null )
              {
                fieldValue = dataGridItemProperty.GetValue( item );
              }
            }

            // If none was found, create a BindingPathValueExtractor from this column
            if( ( dataGridCollectionViewBase == null ) || ( dataGridItemProperty == null ) )
            {
              // We don't have a DataGridCollectionView, use a BindingPathValueExtractor
              // to create a binding to help us get the value for the Column in the 
              // data item
              BindingPathValueExtractor extractorForRead = null;

              if( m_columnToBindingPathExtractor.TryGetValue( column, out extractorForRead ) == false )
              {
                extractorForRead = dataGridContext.GetBindingPathExtractorForColumn( column, item );
                m_columnToBindingPathExtractor.Add( column, extractorForRead );
              }

              fieldValue = extractorForRead.GetValueFromItem( item );
            }
          }

          if( fieldValue != null )
          {
            //Verify if the value should be converted to the displayed value for exporting.
            ForeignKeyConfiguration foreignKeyConfiguration = column.ForeignKeyConfiguration;

            if( foreignKeyConfiguration != null && foreignKeyConfiguration.UseDisplayedValueWhenExporting )
            {
              fieldValue = foreignKeyConfiguration.GetDisplayMemberValue( fieldValue );
            }
            else if( column.DisplayedValueConverter != null )
            {
              fieldValue = column.DisplayedValueConverter.Convert( fieldValue, typeof( object ), column.DisplayedValueConverterParameter, column.GetCulture( column.DisplayedValueConverterCulture ) );
            }
            else if( !string.IsNullOrEmpty( column.CellContentStringFormat ) )
            {
              fieldValue = string.Format( column.GetCulture(), column.CellContentStringFormat, fieldValue );
            }
          }

          clipboardExporter.StartDataItemField( dataGridContext, column, fieldValue );
          clipboardExporter.EndDataItemField( dataGridContext, column, fieldValue );
        }

        clipboardExporter.EndDataItem( dataGridContext, item );
      }
开发者ID:austinedeveloper,项目名称:WpfExtendedToolkit,代码行数:91,代码来源:ClipboardExporterBase.cs

示例2: ExportDataItemCore

      private void ExportDataItemCore(
        DataGridContext dataGridContext,
        ClipboardExporterBase clipboardExporter,
        int itemIndex,
        object item,
        int[] exportedVisiblePositions,
        ColumnBase[] columnsByVisiblePosition )
      {
        DataGridCollectionViewBase dataGridCollectionViewBase =
          dataGridContext.ItemsSourceCollection as DataGridCollectionViewBase;

        clipboardExporter.StartDataItem( dataGridContext, item );

        // Ensure the count does not exceeds the columns count
        int exportedVisiblePositionsCount = exportedVisiblePositions.Length;
        exportedVisiblePositionsCount = Math.Min( exportedVisiblePositionsCount, columnsByVisiblePosition.Length );

        HashSet<int> intersectedIndexes = this.GetIntersectedRangesForIndex( dataGridContext,
            itemIndex,
            exportedVisiblePositions,
            exportedVisiblePositionsCount );

        object fieldValue = null;
        Column column = null;

        for( int i = 0; i < exportedVisiblePositionsCount; i++ )
        {
          int visiblePosition = exportedVisiblePositions[ i ];

          // Export null if not intersected by a SelectionRange
          if( intersectedIndexes.Contains( visiblePosition ) )
          {
            // Only export visible data column
            column = columnsByVisiblePosition[ visiblePosition ] as Column;

            if( column == null )
              continue;

            // Reset field value
            fieldValue = null;

            // Use DataGridCollectionView directly since the DataGridItemProperty uses PropertyDescriptor which increase
            // the read of the field value
            DataGridItemPropertyBase dataGridItemProperty = null;

            // Try to get a DataGridItemProperty matching the column FieldName
            // and get the value from it
            if( dataGridCollectionViewBase != null )
            {
              dataGridItemProperty = dataGridCollectionViewBase.ItemProperties[ column.FieldName ];

              if( dataGridItemProperty != null )
                fieldValue = dataGridItemProperty.GetValue( item );
            }

            // If none was found, create a BindingPathValueExtractor from this column
            if( ( dataGridCollectionViewBase == null ) || ( dataGridItemProperty == null ) )
            {
              // We don't have a DataGridCollectionView, use a BindingPathValueExtractor
              // to create a binding to help us get the value for the Column in the 
              // data item
              BindingPathValueExtractor extractorForRead = null;

              if( m_columnToBindingPathExtractor.TryGetValue( column, out extractorForRead ) == false )
              {
                extractorForRead = dataGridContext.GetBindingPathExtractorForColumn( column, item );
                m_columnToBindingPathExtractor.Add( column, extractorForRead );
              }

              fieldValue = extractorForRead.GetValueFromItem( item );
            }
          }

          clipboardExporter.StartDataItemField( dataGridContext, column, fieldValue );
          clipboardExporter.EndDataItemField( dataGridContext, column, fieldValue );
        }

        clipboardExporter.EndDataItem( dataGridContext, item );
      }
开发者ID:wangws556,项目名称:duoduo-chat,代码行数:79,代码来源:ClipboardExporterBase.cs


注:本文中的DataGridContext.GetBindingPathExtractorForColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。