views:

41

answers:

1

Hi!

I'm writing my own UserControl which displays data in a ListBox. I want to achieve something similar to a property like "DisplayMemberPath". In my example, it's "EditableMemberPath", which should determine which member will be displayed in the textbox. However, using a binding on a binding does not work.

<ListBox ItemsSource="{Binding Path=Items, ElementName=me}"
         SelectedItem="{Binding Path=SelectedItem, ElementName=me}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel>
                <Image Source="{Binding Converter={Binding Path=ItemToImageConverter, ElementName=me}}" />

                <TextBlock Text="{Binding Path={Binding Path=EditableMemberPath, ElementName=me}}" />
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

Can you help me finding a proper solution?

Best Regards
Oliver Hanappi

+1  A: 

You can't do that directly in XAML (at least not with the built-in classes) : a Binding is not a DependencyObject, so you can't bind its properties.

However the post mentioned by Martin Harris looks promising...

Thomas Levesque