This is a migrated thread and some comments may be shown as answers.

Tab control and RadComboBox ItemsSource Binding

2 Answers 102 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 24 May 2011, 09:42 PM
I think I found a bug when I try to repopulate a RadTabControl and I have a radcombobox whose ItemsSource is binding.
First off I set
myTabControl.DataContext = myBigClassOfStuff;  //This class has many objects including a list for the ItemsSource of the radcombobox

Say I click a button and when I get my new result of myBigClassOfStuff, I again call:
myTabControl.DataContext = myBigClassOfStuff;

For all textboxes and radcomboboxes that don't have their ItemsSource binding (but ItemsSource set programatically in the code), everything is fine.  The radComboxes that do have their itemsource filled, but the selected item isn't selected.  Also the value of
myBigClassOfStuff.selectedValue will become null if myTabControl.DataContext already has a value.
If I do this:
myTabControl.DataContext = null;
myTabControl.DataContext = myBigClassOfStuff;

Then everything is almost ok and myBigClassOfStuff.selectedValue will keep it's original value.  This would be fine, but there is one more strange thing the tab control does.   When I do that and I'm on a different tab than the radcombobox I'm interested in, the selected value won't show up when I go to that tab.  When I'm on that tab and get my new myBigClassOfStuff everything is fine though.
When I programatically populate the dropdown boxes everything is ok.  Maybe I'll just do that.  Any suggestions, or things I'm doing wrong?

myBigClassOfStuff.AllContacts  - is a list of a class
myBigClassOfStuff.AttentionId  - is the selected value of the RadComboBox
<telerik:RadComboBox ItemsSource="{Binding AllContacts}"  SelectedValue="{Binding AttentionId}" ...



2 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 27 May 2011, 03:29 PM
Hi danparker276,

I couldn't reproduce your issue on our side but I am not really sure if I understand your scenario correctly.

Basically when I bind the RadComboBox.SelectedItem and the RadTabControl.SelectedItem properties with TwoWay binding and I implement INotifyPropertyChanged in my business class, the control works as expected.

However, by default the RadTabControl creates only one ContentPresenter for the currently selected TabItem and uses it to display the content of this TabItem. Then when you select another RadTabItem, its content is rendered in the same ContentPresenter and therefore the content of the previously selected item is removed from the visual tree thus not holding its state.

If you want to change that behavior and keep each RadTabItem's Content you can set the RadTabControl.IsContentPreserved property to True. That might help you get over your issues.

Still, I attached the sample project I created to test your scenario so that you can have a look at it and let me know if it works for you or if I am missing something.

Regards,
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
0
danparker276
Top achievements
Rank 2
answered on 27 May 2011, 05:25 PM
Thanks "RadTabControl.IsContentPreserved property to True " did the trick.

Tags
TabControl
Asked by
danparker276
Top achievements
Rank 2
Answers by
Tina Stancheva
Telerik team
danparker276
Top achievements
Rank 2
Share this question
or