Click here to Skip to main content
14,458,335 members
Rate this:
Please Sign up or sign in to vote.
See more:
My program is to Delete the items in Listbox, when the user clicks DELETE button Checkbox will appear inside listbox items. then user will select checkbox which one to be delete from list..

How can do coding for this ??


What I have tried:

<pre> <ListBox x:Name="ListBox_PhoneNumber" Margin="235,39,102,0" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="1" Grid.RowSpan="3" FontSize="13" FontWeight="Bold">
       <ListBox.Resources>
          <Style TargetType="ListBoxItem">
              <Setter Property="OverridesDefaultStyle" Value="true" />
              <Setter Property="SnapsToDevicePixels" Value="true" />
              <Setter Property="Template">
              <Setter.Value>
       <ControlTemplate TargetType="ListBoxItem">
    <CheckBox Margin="5,2" x:Name="Chk_Listbox" IsChecked="{TemplateBinding IsSelected}">
  <ContentPresenter />
</CheckBox>
          </ControlTemplate>
      </Setter.Value>
      </Setter>
     </Style>
   </ListBox.Resources>
  </ListBox>
<Button Style="{StaticResource ButtonTopBar}" Content="Delete" x:Name="Button_DltSOTA_Authen" HorizontalAlignment="Right" Width="100" Grid.Column="3" Grid.Row="4" FontSize="14" VerticalAlignment="Bottom" Margin="0,0,49,85" Click="Button_DltSOTA_Authen_Click_1" />
Posted
Comments
Gerry Schmitz 19-Dec-19 11:20am
   
The checkbox in redundant: select one or more items, press delete button, delete "selected" items.

https://docs.microsoft.com/en-us/dotnet/api/system.windows.controls.listbox.selectionmode?view=netframework-4.8

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100