Hi,
I am having difficulties in specifying the Expression property of the GridViewExpressionColumn in Xaml.
I have this column that I want to turn into a expression column :
I am having difficulties in specifying the Expression property of the GridViewExpressionColumn in Xaml.
I have this column that I want to turn into a expression column :
<telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Attributes.[PERCEELID]}" Header="PerceelId" DataType="{x:Type sys:Int32}" /> First step, make ik a GridViewExpressionColumn :<telerik:GridViewExpressionColumn UniqueName="Opp" Header="Oppervlakte (ha)" Expression="Attributes["PERCEELID"]" />So far so good, this still displays the same result as my original column (nothing calculated so far).
But as soon as I want to do something with this value, nothing is shown and I receive errors in the output window.
This is about the simplest expression I can think of (multiplying by 2) :
<telerik:GridViewExpressionColumn UniqueName="Opp" Header="Oppervlakte (ha)" Expression="Attributes["PERCEELID"] * 2" />The column stays empty and the outpunt window shows :
A first chance exception of type 'System.ArgumentException' occurred in System.ComponentModel.DataAnnotations.dll
A first chance exception of type 'System.InvalidOperationException' occurred in System.Core.dll
I have tried to explicitely cast my value first before multiplying (Convert.ToInt32(Attributes["PERCEELID"]) * 2); but no success.
If I do the same in code-behind, there is no problem :
Expression<Func<Graphic, double>> expression = g => (int)g.Attributes["PERCEELID"] * 2; var c = this.GevondenPercelenDataGrid.Columns["Opp"] as GridViewExpressionColumn; c.Expression = expression;
The ToString() of this expression yields:
"g => Convert((Convert(g.Attributes.get_Item(\"PERCEELID\")) * 2))"
Using this string as value for "Expression" in the xaml is no solution either.
Can anyone give me some tips on building expressions in xaml ?
Kind regards,
Martin