Hello Ross,
thanks for your reply. I have already seen your documentation and examples. They helped me to try some things out but I was not able to get the binding work properly.
The following things I tried:
private
Binding PrepareDataMemberBinding(
string
key)
{
return
new
Binding()
{
Path =
new
PropertyPath(
"Attributes"
),
Converter =
new
DictionaryConverter(key)
};
}
private
function BindDataGrid()
{
// radSourceObjectGridView is RadDataGrid
// radDataFilter is RadDataFilter ;)
foreach
(var item
in
_originalObjectFeatureSet.Features[0].Attributes)
{
var dataColumn =
new
GridViewDataColumn()
{
Header = item.Key,
DataType = item.Value.GetType(),
DataMemberBinding = PrepareDataMemberBinding(item.Key)
};
radSourceObjectGridView.Columns.Add(dataColumn);
}
//_originalObjectFeatureSet.Features contains a Dictionary<string, object> Attributes from where the data comes
radSourceObjectGridView.ItemsSource = _originalObjectFeatureSet.Features;
//Now I want to use the RadDataFilter to filter the RadGridView but I have no idea how to do this
// 1. Binding doesn't work the right way
radDataFilter.Source = _originalObjectFeatureSet.Features
radSourceObjectGridView.ItemsSource = radDataFilter.FilteredSource;
// 2. I also tried to generate a special binding without success
radDataFilter.Source = MakeSpecialBinding(...);
// 3. The next idea was to implement a self-written filter logic ...
var filterPropertyList =
new
List<ItemPropertyInfo>();
foreach
(var item
in
_originalObjectFeatureSet.Features[0].Attributes)
{
var filterFieldInfo =
new
ItemPropertyInfo(item.Key, item.Value.GetType(),
null
);
filterPropertyList.Add(filterFieldInfo);
}
radDataFilter.ItemProperties = filterPropertyList;
radDataFilter.FilterDescriptors.CollectionChanged +=
new
System.Collections.Specialized.NotifyCollectionChangedEventHandler(FilterDescriptors_CollectionChanged);
radDataFilter.FilterDescriptors.ItemChanged +=
new
EventHandler<ItemChangedEventArgs<IFilterDescriptor>>(FilterDescriptors_ItemChanged);
// ... but Silverlight hangs if I use code like this
radSourceObjectGridView.FilterDescriptors.Clear();
foreach
(var item
in
radDataFilter.FilterDescriptors)
{
radSourceObjectGridView.FilterDescriptors.Add(item);
}
}
Now I try to go another way by using an anonymous object class where the data from the dictionary is copied to:
class AnonObject
{
StringOrDouble Field01;
StringOrDouble Field02;
StringOrDouble Field03;
...
}
It is not a very nice solution because we lose a bit of the dynamic behaviour.
Regards,
Benjamin