I have a ListBox displaying items with a template something like this:
<ListBox
x:Name="CustomerResultList"
ItemsSource="{Binding Customers}">
<ListBox.ItemTemplate>
<DataTemplate>
<controlsToolkit:DockPanel>
<Button
x:Name="CustomerButton"
Command="{Binding MyCommand}"
CommandParameter="{Binding WhatGoesHere?}"
controlsToolkit:DockPanel.Dock="Left"
Content="ButtonText" />
<TextBlock
Text="{Binding Path=Name}"
controlsToolkit:DockPanel.Dock="Right" />
</controlsToolkit:DockPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The button in the template should invoke a command that gets passed the customer as a parameter.
I can’t figure out how to refer to the customer in the buttons CommandParameter binding.
Is there a special Elementname or Path I can use to refer to the Custome itself and not some of its properties?
Simply:
If you specify
BindingwithoutPath, you bind to theDataContextitself.