tags:

views:

28

answers:

1

Hi

I have created a listbox control with following DataTemplate

<DataTemplate x:Key="lb_Itemtemplate">
    <DockPanel>
        <TextBlock Text="{Binding}" DockPanel.Dock="Left"  />    
        <Button DockPanel.Dock="Right" Template="{StaticResource ButtonTemplate }" 
                            Width="20" Margin=" 0,1,1,10" >Delete </Button>
        <Button DockPanel.Dock="Right" Template="{StaticResource ButtonTemplate }" 
                            Width="20" Margin="0,1,1,10" >Highlight </Button>
    </DockPanel>
</DataTemplate>

<ListBox Name="listBox1" Grid.Column="0"  Grid.Row="1" 
              DataContext="{Binding ElementName=cb_fields, Path=SelectedItem}"
              ItemsSource="{Binding Path=PositiveXPathExpressions}"
              ItemTemplate="{StaticResource lb_Itemtemplate}" />

I want to delete element from "PositiveXPathExpressions" collection when user clicked on button "delete" but How i can decide which element i must to delete?

A: 

Your question is closely related to http://stackoverflow.com/questions/2608187/wpf-listview-selecteditem-is-null/2608315#2608315

Veer