DataMemberBinding="{Binding Path=Days[1]}"
("Days" is an Array like Days[10])
I get the following error in the Visual Studio debug output window:
A first chance exception of type 'System.ArgumentException' occurred in Telerik.Windows.Data.dll
and the filter menu button in the column header is missing and the sorting function doesn't work anymore.
If I wrap the array element in a porperty in the business object and use this for binding, everything is fine. What's going on here?
Thanks
5 Answers, 1 is accepted
Unfortunately, I am not capable of reproducing the issue you specified as your requirements and settings are not quite clear. What exactly is your scenario ? How do you define the array Days[ ] ? What is the reason you do not want to use a property for that particular column ?
Maya
the Telerik team

Consider the following (stripped-down):
I use the MVVM pattern.
The View contains a RadGridView with a few defined Columns in XAML like:
<
tk:RadGridView
ItemsSource="{Binding GridItems, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False">
<
tk:RadGridView.Columns>
<
tk:GridViewDataColumn
DataMemberBinding
=
"{Binding Days[0]}"
UniqueName
=
"Days1"
</tk:GridViewDataColumn>
<
tk:GridViewDataColumn
DataMemberBinding
=
"{Binding Days[1]}"
UniqueName
=
"Days2"
</tk:GridViewDataColumn>
...
</tk:RadGridView>
In the ViewModel which acts as DataContext to the View I have the following property:
private
ObservableCollection<BusinessClass1> _GridItems;
public
ObservableCollection<BusinessClass1> GridItems
{
get
{
return
_GridItems; }
set
{
_GridItems = value;
OnPropertyChanged(
"GridItems"
);
}
}
Class BusinessClass1 consists of the following:
class
BusinessClass1
{
private
decimal
[] _Days =
new
decimal
[14];
public
decimal
[] Days
{
get
{
return
_Days; }
set
{ _Days = value; }
}
}
I hope I could clarify my setup.
I am still not quite sure what is the exact scenario you are trying to achieve so I am not able to provide you with any appropriate solution for the time being. I prepared a sample project using the code-snippet you provided. Please take a look at it and share more information if there is some misunderstanding according to your requirements.
Maya
the Telerik team

Looking through your project files in an editor the example should produce the same issues I had, only the "GetDays()" call in the GridItems property getter in MyViewModel I'm not quite sure of. With "return _GridItems;" it would be more in line with my code.
I'll try to explain what I want to do again:
I want to bind column data of an GridView to elements of an array, i. e. array element with index 0 is bound to column1, array element with index 1 is bound to column 2 and so on. This works in WPF with the following notation: for example for a textbox:
<TextBox Text={Binding Path=Days[0]}></TextBox>
where Days[0] is element 1 in an array. If it works generally in WPF, it should work with your GridView, too, right?
But if I do this in that way (and you seem to get it in your sample project), I get the problems described in the first post (Filter Menu Button in column header dissapears, no sorting possible anymore ...). Strangely enough despite the problems, the data is displayed in the GridView.
Firstly, please excuse me for the misunderstanding according to the type of Platform you are using.
I have modified the sample project so that it fits your requirements. Basically, the behavior you are getting of not being able to sort and filter the columns is not the expected one. We would investigate the issue and it has already been logged into our Public Issue Tracking System. You may follow its progress by its ID - 3611 - "RadGridView: No sorting/filtering functionality is enabled when the ItemsSource is type of decimal array".
As a possible workaround, I may suggest you to set the DataType Property of the column:
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Path=Days[0]}"
Header
=
"Day1"
DataType
=
"{x:Type system:Decimal}"
/>
Another possible approach may be to use a List instead of array.
Maya
the Telerik team