BindingExpressionBase
Posted: 08 Dec 2019, 18:03
Try to work out how to do binding against a ListView column through C# and bumping into some issues...
This works fine in a XAML file, loading the xaml and data binding objects to it. Great.
I'm trying to work out how to do the same thing in code, to be able to change the columns at runtime.
Inspecting the resulting objects from the XAML above gives the DisplayMemberBinding property of the GridViewColumn.
It's set to a BindingExpressionBase object.
BindingExpressionBase, or BindingExpression don't have useful constructors.
I thought I could use BindingOperations.SetBinding(target, dp) to get a BindingExpressionBase, but GridViewColumn doesn't have a DisplayMemberPathProperty to attach too.
Any ideas?
Thanks
Chris
Code: Select all
<ListView x:Name="InventoryItemList" Grid.Row="1" Margin="4" ItemsSource="{Binding ItemsList}">
<ListView.View>
<GridView>
<GridViewColumn Header="Item" Width="96" DisplayMemberBinding="{Binding Item}" />
<GridViewColumn Header="Quantity" Width="64" DisplayMemberBinding="{Binding Quantity}" />
</GridView>
</ListView.View>
</ListView>
I'm trying to work out how to do the same thing in code, to be able to change the columns at runtime.
Inspecting the resulting objects from the XAML above gives the DisplayMemberBinding property of the GridViewColumn.
It's set to a BindingExpressionBase object.
BindingExpressionBase, or BindingExpression don't have useful constructors.
I thought I could use BindingOperations.SetBinding(target, dp) to get a BindingExpressionBase, but GridViewColumn doesn't have a DisplayMemberPathProperty to attach too.
Any ideas?
Thanks
Chris