Thank you in advance.
7 Answers, 1 is accepted
You can simply bind the IsChecked property of the RadioButton to the property of your business object. You can do this directly in the DataTemplate, you don't need to reference the radio button explicitely.
<DataTemplate>
...
<telerik:RadRadioButton IsChecked="{Binding IsSelected}" .../>
...
</DataTemplate>
Please let us know if you still have any problems. You can send us a the sample code that is not working.
Regards,
Valentin.Stoychev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Please take a look at the sample project that I prepared for you and let me know if it helps.
It demonstrates how to keep the state of the radio button and the selected item in the listbox in synch.
Please let us know if your scenario requires an approach different than the one on the sample.
Regards,
Tina Stancheva
the Telerik team
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
I modified the listBox_SelectionChanged() method in the example and removed the IsChecked property in the business object.
Please take a look at the new example and let us know if you need more info.
All the best,
Tina Stancheva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
listBox.ItemContainerGenerator.ContainerFromItem(e.AddedItems[0])
as System.Windows.Controls.ListBoxItem to get a reference to the ListBoxItem. So, thank you for that insight. I have also found another solution that uses the Loaded event of the UIControl defined in the DataTemplate to apply custom logic once the control has been loaded.
List<misdatos> sele = new List<misdatos>();
private void list_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.RemovedItems.Count!=0)
{
sele.Remove(e.RemovedItems[0] as misdatos);
txtseleccion.Text = sele.Count.ToString();
}
if (e.AddedItems.Count != 0)
{
sele.Add(e.AddedItems[0] as misdatos);
txtseleccion.Text = sele.Count.ToString();
}
}