views:

584

answers:

0

I am using an AutoCompleteBox defined as:

    <Controls:AutoCompleteBox
        Margin="4" 
        Grid.Column="1"
        Width="120"
        VerticalAlignment="Center"
        ItemsSource="{Binding Routes}"
        ItemTemplate="{StaticResource RouteItemDataTemplate}"
        ValueMemberPath="Name"
        Style="{StaticResource AutoCompleteComboBoxStyle}"
        SelectedItem="{Binding Path=BindingRoot.Route, Mode=TwoWay}"
        />

I have a DataTemplate that pulls the appropriate bits (the Name property) of a custom DTO class. The display in the popup renders the search results correctly, and also the ValueMemberPath is working because the selected item is rendered correctly in the textbox internal to the AutoCompleteBox as well. Everything is working great... Except for the fact when I try to define a custom ItemFilter. In my implementation, I try to inspect the item passed into my method, and I do a runtime check on the value of ValueMemberPath (which is not a DP, but a regular CLR property). I need the value of the VMP property because I want to use reflection to pull in the correct field which I need to make in my custom ItemFilter comparison logic. However, programmatically, ValueMemberPath is always null. Indeed, if I swap out ValueMemberPath, and use:

ValueMemberBinding="{Binding Path=Name}"

I get the same result => BOTH properties are null during runtime.

What gives? Any ideas?

I notice that the two properties work in tandem. So if I only define VMP, but not VMB, a Binding object gets created for me anyways...

Thanks