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; }
}