Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
hi! i have a listbox binded to a list. the list contains checkboxes binded to a field/member of the list. what i want to achieve is that i want to delete the data from list when it's corresponding checkbox is checked...

here's my xaml code:
XML
<ListBox Name="ListBox1" ItemsSource="{Binding histList, Mode=OneWay}" Margin="10,10,10,10" Height="197" VerticalAlignment="Center" >
    <ListBox.ItemTemplate>
        <DataTemplate>
            <CheckBox Content="{Binding FilterName, Mode=TwoWay}" />
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>


here's the code in the .cs file
C#
namespace ReportsUIScreens
{
    public partial class EditStyle : ChildWindow
    {
        private List<filterHistory> histList;
        public EditStyle(List<filterHistory> histListLink)
        {
            InitializeComponent();
            histList = histListLink;
            this.ListBox1.ItemsSource=histList;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            //HERE'S WHERE I WANT TO DELETE
            this.DialogResult = true;
        }
        .........
        .........
        .........
    }
}


please help me...
Posted

1 solution

You will need to bind to the checkbox checked property and remove an item from the list box in your code behind.
 
Share this answer
 
Comments
Member 7838027 30-Apr-11 23:56pm    
can you please give me the code to do that? thanks :)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900