Click here to Skip to main content
15,905,558 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have listBox filled with checkItems
I want to get items values string of checked Items List Box Using wpf .

What I have tried:

I tried this  c# code , But this is work only with checkedlist in c# and not same in wpf 

for (int i = 0; i < ListBox.Items.CheckedItems.Count; ++i)
          {
        string ItemValue =ListBox.CheckedItems[i]ToString();
          }


But I can get only selected Items from listBox wpf using this and its not what I want :

For  (int i = 0; i < ListBox.Items.SelectedItems.Count; ++i)
          {
        string ItemValue =ListBox.SelectedItems[i]ToString();
          }


How can I get checked Items Values from listBox using wpf ? Thank you for any help and attention .
Posted
Updated 19-Oct-18 3:19am

1 solution

  foreach (CheckBox item in ListBox.Items)
                    {
                        if (item.IsChecked == true)
                        {
                            string ItemValue =item.Content.ToString() ;

}}
 
Share this answer
 

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