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

ComboBoxItems not found when using ControlTemplate

2 Answers 52 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
donovan
Top achievements
Rank 1
donovan asked on 16 Apr 2014, 04:51 AM
Hello

I'm having an issue where the ComboBoxItems are not being recognized in Silverlight. I am using a standard ComboBox with the attached style.

Other Combo Boxes seem to work find but this one uses a Control template with some additional features. When I view it in SilverlightSpy I can see the items fine (see attached).

My code
            var combo = _silverlightApp.Find.ByName<ComboBox>("cbFacilityTypes");
            //Items = null

I have tired 
            combo.Find.ByType<ComboBoxItem>();
            combo.Find.ByType<TextBox>();
            combo.IsDropDownOpen = true;            
            combo.Refresh();
            combo.ItemsPopup.Refresh();
           //looping through children the ScrollContentPresenter is always empty.
           //in the screen I can see it expanding the right combo but it just cant find any of the child controls but I can see them in SilverlightSpy

Any help much appreciated
Thanks







2 Answers, 1 is accepted

Sort by
0
donovan
Top achievements
Rank 1
answered on 16 Apr 2014, 05:13 AM
Apologies seems this was posted twice.

I have a work around :) 

var cb = _silverlightApp.Find.ByName<ComboBox>("cbFacilityTypes");
cb.IsDropDownOpen = true;
_silverlightApp.RefreshVisualTrees();
var cb = _silverlightApp.Find.ByName<ComboBox>("cbFacilityTypes");
//now has items



0
Konstantin Petkov
Telerik team
answered on 17 Apr 2014, 09:56 AM
Hello,

No problem about the duplicate!

As to the code, it looks just fine. The RefreshVisualTrees() method takes care of updating all the popups within the scope of the element (MS ComboBox in this case) so that the test code can proceed with the up to date visual tree.

Regards,
Konstantin Petkov
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
donovan
Top achievements
Rank 1
Answers by
donovan
Top achievements
Rank 1
Konstantin Petkov
Telerik team
Share this question
or