0

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?

CAbbott
  • 8,078
  • 4
  • 31
  • 38
Neir0
  • 12,849
  • 28
  • 83
  • 139

1 Answers1

0

Your question is closely related to WPF ListView SelectedItem is null

Community
  • 1
  • 1
Amsakanna
  • 12,254
  • 8
  • 46
  • 58