Home Forums WPF controls Xceed DataGrid for WPF v1.2 Bug when using DataColumn.Expression and Filter

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #24548 |

    I have dataset with one table named ‘Table’ which has two columns called ‘Value1’ and ‘Value2’ and one with expression called ‘Total’

    Here is xsd definition

    <?xml version=”1.0″ encoding=”utf-8″?>
    <xs:schema id=”DataSet1″ targetNamespace=”http://tempuri.org/DataSet1.xsd&#8221; xmlns:mstns=”http://tempuri.org/DataSet1.xsd&#8221; xmlns=”http://tempuri.org/DataSet1.xsd&#8221; xmlns:xs=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:msdata=”urn:schemas-microsoft-com:xml-msdata” xmlns:msprop=”urn:schemas-microsoft-com:xml-msprop” attributeFormDefault=”qualified” elementFormDefault=”qualified”>
    <xs:annotation>
    <xs:appinfo source=”urn:schemas-microsoft-com:xml-msdatasource”>
    <DataSource DefaultConnectionIndex=”0″ FunctionsComponentName=”QueriesTableAdapter” Modifier=”AutoLayout, AnsiClass, Class, Public” SchemaSerializationMode=”IncludeSchema” xmlns=”urn:schemas-microsoft-com:xml-msdatasource”>
    <Connections>
    </Connections>
    <Tables>
    </Tables>
    <Sources>
    </Sources>
    </DataSource>
    </xs:appinfo>
    </xs:annotation>
    <xs:element name=”DataSet1″ msdata:IsDataSet=”true” msdata:UseCurrentLocale=”true” msprop:Generator_UserDSName=”DataSet1″ msprop:Generator_DataSetName=”DataSet1″>
    <xs:complexType>
    <xs:choice minOccurs=”0″ maxOccurs=”unbounded”>
    <xs:element name=”Table” msprop:Generator_UserTableName=”Table” msprop:Generator_RowDeletedName=”TableRowDeleted” msprop:Generator_TableClassName=”TableDataTable” msprop:Generator_RowChangedName=”TableRowChanged” msprop:Generator_RowClassName=”TableRow” msprop:Generator_RowChangingName=”TableRowChanging” msprop:Generator_RowEvArgName=”TableRowChangeEvent” msprop:Generator_RowEvHandlerName=”TableRowChangeEventHandler” msprop:Generator_TablePropName=”Table” msprop:Generator_TableVarName=”tableTable” msprop:Generator_RowDeletingName=”TableRowDeleting”>
    <xs:complexType>
    <xs:sequence>
    <xs:element name=”Id” msdata:AutoIncrement=”true” msdata:AutoIncrementSeed=”-1″ msdata:AutoIncrementStep=”-1″ msprop:Generator_UserColumnName=”Id” msprop:Generator_ColumnPropNameInRow=”Id” msprop:Generator_ColumnVarNameInTable=”columnId” msprop:Generator_ColumnPropNameInTable=”IdColumn” type=”xs:int” />
    <xs:element name=”Value1″ msprop:Generator_UserColumnName=”Value1″ msprop:Generator_ColumnPropNameInRow=”Value1″ msprop:Generator_ColumnVarNameInTable=”columnValue1″ msprop:Generator_ColumnPropNameInTable=”Value1Column” type=”xs:double” minOccurs=”0″ />
    <xs:element name=”Value2″ msprop:Generator_UserColumnName=”Value2″ msprop:Generator_ColumnPropNameInRow=”Value2″ msprop:Generator_ColumnVarNameInTable=”columnValue2″ msprop:Generator_ColumnPropNameInTable=”Value2Column” type=”xs:double” minOccurs=”0″ />
    <xs:element name=”Total” msdata:ReadOnly=”true” msdata:Expression=”isnull(Value1,0)+isnull(Value2,0)” msprop:Generator_UserColumnName=”Total” msprop:Generator_ColumnPropNameInRow=”Total” msprop:Generator_ColumnVarNameInTable=”columnTotal” msprop:Generator_ColumnPropNameInTable=”TotalColumn” type=”xs:double” minOccurs=”0″ />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:choice>
    </xs:complexType>
    <xs:unique name=”DataTable1Key1″ msdata:PrimaryKey=”true”>
    <xs:selector xpath=”.//mstns:Table” />
    <xs:field xpath=”mstns:Id” />
    </xs:unique>
    </xs:element>
    </xs:schema>

    When I have datagrid which I Filter i have NullreferenceException every time I add new row to the table.
    Here is Window1.xaml file

    <Window x:Class=”ExpressionBugRepro.Window1″
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid&#8221;
    xmlns:ExpressionBugRepro=”clr-namespace:ExpressionBugRepro;assembly=”
    Title=”ExpressionBugRepro” Height=”480″ Width=”640″
    >
    <Window.Resources>
    <ExpressionBugRepro:DataSet1 x:Key=”dataset”/>
    <xcdg:DataGridCollectionViewSource x:Key=”viewsource” Source=”{Binding Source={StaticResource dataset}, Path=Table}” Filter=”source_Filter”/>
    </Window.Resources>
    <StackPanel>
    <Button x:Name=”btn” Content=”Click to add record”/>
    <xcdg:DataGridControl ItemsSource=”{Binding Source={StaticResource viewsource}}” ReadOnly=”True” Height=”300″ AutoCreateColumns=”False”>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”Value1″ Title=”Nov” Width=”50″/>
    <xcdg:Column FieldName=”Value2″ Title=”Dec” Width=”50″/>
    <xcdg:Column FieldName=”Total” Title=”Total” Width=”100″/>
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>
    </StackPanel>
    </Window>

    and my code

    public partial class Window1 : System.Windows.Window
    {

    public Window1()
    {
    InitializeComponent();
    btn.Click += btn_Click;
    }

    void btn_Click(object sender, RoutedEventArgs e)
    {
    DataSet1 ds = Resources[“dataset”] as DataSet1;
    DataSet1.TableRow row = ds.Table.NewTableRow();
    row[“Value1”] = new Random().NextDouble() * 10;
    row[“Value2”] = new Random().NextDouble()*10;
    ds.Table.AddTableRow(row);

    row = ds.Table.NewTableRow();
    row[“Value1”] = new Random().NextDouble() * 10;
    row[“Value2”] = new Random().NextDouble() * 10;
    ds.Table.AddTableRow(row);
    }

    void source_Filter(object sender, DataGridFilterEventArgs e)
    {
    DataSet1.TableRow row = e.Item as DataSet1.TableRow;
    e.Accepted = row.Value1 > 4;
    }
    }

    NullReferenceException occurs only when I filter using DataGridCollectionViewSource.Filter and when in table there is one column with Expression set.
    It occurs when ‘ds.Table.AddTableRow(row);’ is executed.

    Any workarounds ??

    Imported from legacy forums. Posted by Remigiusz (had 694 views)

    Xceed Support
    Member
    Post count: 5658

    Can you provide the complete stack trace of the exception?

    Imported from legacy forums. Posted by Marcus [Xceed] (had 2793 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.