This project is read-only.

Unable to bind columns to child property of an object


The collection my DataGrid is bound to contains objects with child properties. Autofilter does not work for these child properties.
<DataGrid ItemsSource="{Binding Files}" AutoGenerateColumns="False">
        <DataGridTextColumn Binding="{Binding ID}" Header="Id" />
        <DataGridTextColumn Binding="{Binding Name}" Header="Name" />
        <DataGridTextColumn Binding="{Binding Details.Size}" Header="Size" />

When I use the following binding, the filter does work, but the grid shows an empty column because the binding is invalid:
<DataGridTextColumn Binding="{Binding Source=Details, Path=Size}" Header="Size" />
Do you know how to fix this issue?

file attachments


BorisUK wrote Jan 27, 2015 at 2:50 PM

I have been able to solve the problem partially using bsFilter:ColumnFilter.BindingPath property:
                <DataGridTextColumn Binding="{Binding Details.Size}" Header="Size" bsFilter:ColumnFilter.BindingPath="Size" />
However, this does not seem to work when binding to Entity Framework objects.

Mishkin wrote Jan 28, 2015 at 12:57 PM

For complex binding, it is need to implement next (from v1.1.0.1):
  public class FileSizeFIM : BolapanControl.ItemsFilter.Initializer.FilterInitializersManager {
        public FileSizeFIM() {
            Add(new FileSizeValueFilterInitializer());
            // Add other filter initializers there...
    public class FileSizeValueFilterInitializer : BolapanControl.ItemsFilter.Initializer.FilterInitializer {
        public override Filter NewFilter(BolapanControl.ItemsFilter.FilterPresenter filterPresenter, object key) {
            if (key is string && (string)key == "Details.Size") {// from v1.1.0.1, key with "." pass to initializer
                return new FileSizeValueFilter();
            return null;
    public class FileSizeValueFilter : RangeFilter<long> {
        public FileSizeValueFilter() : base(FileSizeGetter) { }
        private static long FileSizeGetter(object iFile) {
            return ((File)iFile).Details.Size; // Get file size from item of collection
<DataGridTextColumn Binding="{Binding Source=Details, Path=Size}" Header="Size" >
            <vw:FileSizeFIM />
See also binding to column "Supplier" in form ProductsView.xaml (v1.1.0.1) and file SupplierNameFIM.cs