I have a label on the form that I would like to provide feedback to the user:
"Sorted by First Name, Filtered by Last Name like 'Jones'"
My first attempt was to simply bind the label content to the DomainDataSouce FilterDescriptors, passed to an IValueConverter to create the concated description. However, it seems that changing the column filters on the gridView doesn't actually change the FilterDescriptors collection on the DomainDataSource.
My second attempt was to bind the label content to the gridView.FilterDescriptors collection, also passed to an IValueConverter to create the concated description. However, it seems that changes to FilterDescriptors collection do not fire an OnPropertyChanged event, so the value never changes.
I'm sure I'm just overlooking something really simple, but I couldn't find anything similar in the blogs or forums.
Here is my XAML:
<dataInput:Label Style="{StaticResource PanelHeaderStyle}"
HorizontalAlignment="Left"
Content="{Binding FilterDescriptors, Mode=OneWay,
ElementName=gridView, Converter={StaticResource filterDescriptorConverter}}"
Grid.Row="0"/>
Here is the converter:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Telerik.Windows.Data.
FilterDescriptorCollection filters;
try
{
filters = value
as Telerik.Windows.Data.FilterDescriptorCollection;
}
catch (Exception)
{
return string.Empty;
}
if (filters==null) return string.Empty;
if (filters.Count>2)
return string.Format(EntityNames.FilterByName, filters.Count.ToString());
foreach (var filter in filters)
{
// build a filter string such as "Filtered by 'Title'='Book' and 'Subject'='Something'
}
// replace with build filter string.
return string.Empty;
}