I have ribbon with contextual tabs.
I try get access to element with name "TARGET_BUTTON" with UI Automation API.
But this code don't find the button.
If I set in line 20 IsActive="true" then I can find the button.
I use last version of UI for WPF.
01.<telerik:RadRibbonWindow x:Class="WpfApp.MainWindow"03. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"04. xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"05. Title="MainWindow" Height="350" Width="525">06. <telerik:RadRichTextBoxRibbonUI>07. <telerik:RadRibbonTab Header="Tab1">08. <telerik:RadRibbonGroup Header="BBB">09. <telerik:RadToggleButton Name="ToggleButton" Content="Show" />10. </telerik:RadRibbonGroup>11. </telerik:RadRibbonTab>12. 13. <telerik:RadRibbonTab ContextualGroupName="TestTab" Header="Tab2">14. <telerik:RadRibbonGroup Header="AAA">15. <telerik:RadRadioButton Name="TARGET_BUTTON" Content="ClickMe" />16. </telerik:RadRibbonGroup>17. </telerik:RadRibbonTab>18. 19. <telerik:RadRichTextBoxRibbonUI.ContextualGroups>20. <telerik:RadRibbonContextualGroup Header="Test" IsActive="{Binding IsChecked, ElementName=ToggleButton}" Color="BlueViolet" GroupName="TestTab" />21. </telerik:RadRichTextBoxRibbonUI.ContextualGroups>22. </telerik:RadRichTextBoxRibbonUI>23.</telerik:RadRibbonWindow>I try get access to element with name "TARGET_BUTTON" with UI Automation API.
01.var app = AutomationElement.RootElement.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, "My Application"));02.var allChildren = TreeWalker.RawViewWalker.GetParent(app).FindAll(TreeScope.Descendants, Condition.TrueCondition);03. 04.foreach (AutomationElement automationElement in allChildren)05.{06. try07. {08. if (automationElement.Current.AutomationId == "TARGET_BUTTON")09. {10. Console.WriteLine("{0} ({1})", automationElement.Current.ClassName, automationElement.Current.AutomationId);11. } 12. }13. catch { }14.}But this code don't find the button.
If I set in line 20 IsActive="true" then I can find the button.
I use last version of UI for WPF.