jeliey 0 Report post Posted January 25, 2013 need ur help :( Ada sapa2 x yg penah guna WPF? harap2 ada la yg boleh membantu... In my wpf, i have successfully saved the selected checkboxes in my database. But i got issue on how to display the checked checkboxes. Lets say there are 7 checkboxes in total, and user ticked 3 out of them. I was able to retrieve the Checkbox_id from database through webservice, but how to bind it to checkboxes? ni table yg aku save checkbox_id: User_ID : 1 Widget_ID : 1,2,3 It should only checked the selected id (1,2,3), but all i got is the whole checkboxes are checked. Please help me fix this...below is my code: xaml: xaml.cs: XDocument doc = XDocument.Parse(e.Result); var query = from i in doc.Descendants("ResultTable") select i; foreach (XElement item in query) { selectedWidget = item.Element("Widget_ID").Value; } for (Int32 i = LBWidget.Items.Count - 1; i >= 0; i--) { ListBoxItem item = LBWidget.ItemContainerGenerator.ContainerFromIndex(i) as ListBoxItem; ContentPresenter myContentPresenter = FindVisualChild(item); DataTemplate dataTemplate = myContentPresenter.ContentTemplate; CheckBox chk = dataTemplate.FindName("chk", myContentPresenter) as CheckBox; if (selectedWidget != null) { chk.IsChecked = true; } } Quote Share this post Link to post Share on other sites
Chuki2 32 Report post Posted January 25, 2013 Hai jeliey, sebelum post code tersebut.. sila gunakan tag [ C O D E ] [ \ C O D E] untuk memudakan kami membaca kod anda... By the way, check box ini berada didalam list view ke? Quote Share this post Link to post Share on other sites
Chuki2 32 Report post Posted January 29, 2013 Hai jeliey, Try buat macam ini... if (selectedWidget != DBNull.Value) { chk.IsChecked = true; } Gud luck and happy programming....:D Quote Share this post Link to post Share on other sites