Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
XamPivotGrid become black when drag and drop
posted

Hi,

I use the XamPivotGrid and XamPivotDataSelector in an WPF Browser Application.

When I drag and drop a field, the XamPivotGrid(or XamPivotDataSelector ) bacome black.

Please help me.

 

Here is my code:

[xaml]

<Page x:Class="Page1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="1366"
      Title="Page1" xmlns:ig="http://schemas.infragistics.com/xaml">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <ig:XamPivotGrid Name="XamPivotGrid_Result" AllowCompactLayout="True" />
        <ig:Expander Grid.Column="1">
            <ig:XamPivotDataSelector Name="XamPivotDataSelector_Result" />
        </ig:Expander>
    </Grid>
</Page>

 

[xaml.vb]

Imports System.Windows
Imports System.Windows.Controls
Imports System.Data
Imports System.Data.SqlClient
Imports System.Reflection
Imports Infragistics.Olap
Imports Infragistics.Olap.FlatData

Class Page1
    Dim QueryTable As New DataTable With {.TableName = "QueryTable"}

    Public Sub New()
        InitializeComponent()
        BuildDataSource()
    End Sub

    Private Sub BuildDataSource()
        Dim column1 As DataColumn
        column1 = New DataColumn
        QueryTable.Columns.Add(New DataColumn("col1", GetType(String)))
        QueryTable.Columns.Add(New DataColumn("col2", GetType(String)))
        QueryTable.Columns.Add(New DataColumn("val1", GetType(Int32)))
        QueryTable.Columns.Add(New DataColumn("val2", GetType(Int32)))
        For indexA = 1 To 30
            Dim row As DataRow
            row = QueryTable.NewRow()
            row("col1") = "Joe"
            row("col2") = "US"
            row("val1") = indexA
            row("val2") = indexA * indexA
            QueryTable.Rows.Add(row)
        Next indexA

        Dim typeBuilder As New DynamicTypeBuilder() With { _
          .DynamicAssemblyName = "MyAssembly", _
          .DynamicTypeName = QueryTable.TableName _
        }

        Dim properties As IList(Of DynamicTypePropertyInfo) = New List(Of DynamicTypePropertyInfo)()
        For Each column As DataColumn In QueryTable.Columns
            Dim PropertyInfo As New DynamicTypePropertyInfo() With { _
              .PropertyName = column.ColumnName, _
              .PropertyType = column.DataType _
            }
            properties.Add(PropertyInfo)
        Next

        Dim dynamicType As Type = typeBuilder.GenerateType(properties)
        Dim listType As Type = GetType(List(Of ))
        Dim genericListType As Type = listType.MakeGenericType(dynamicType)
        Dim list As IList = DirectCast(Activator.CreateInstance(genericListType), IList)

        For Each dataRow As DataRow In QueryTable.Rows
            Dim myDynamicInstance As Object = Activator.CreateInstance(dynamicType)
            For Each column As DataColumn In QueryTable.Columns
                Dim propertyVal As PropertyInfo = dynamicType.GetProperty(column.ColumnName)
                If IsDBNull(dataRow(column)) = False Then
                    propertyVal.SetValue(myDynamicInstance, dataRow(column), Nothing)
                End If
            Next
            list.Add(myDynamicInstance)
        Next

        Dim flatDataSource As New FlatDataSource() With {
          .ItemsSource = list, _
          .Cube = DataSourceBase.GenerateInitialCube(QueryTable.TableName),
          .Columns = DataSourceBase.GenerateInitialItems("[col1].[col1]"),
          .Rows = DataSourceBase.GenerateInitialItems("[col2].[col2]"),
          .Measures = DataSourceBase.GenerateInitialItems("val1")
        }

        XamPivotGrid_Result.DataSource = flatDataSource
        XamPivotDataSelector_Result.DataSource = flatDataSource

    End Sub
End Class