UI Automation for RadRibbonContextualGroup

2 posts, 0 answers
  1. Igorious
    Igorious avatar
    1 posts
    Member since:
    Sep 2014

    Posted 25 Sep 2014 Link to this post

    I have ribbon with contextual tabs.

    01.<telerik:RadRibbonWindow x:Class="WpfApp.MainWindow"
    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.    try
    07.    {
    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.
  2. Kiril Vandov
    Admin
    Kiril Vandov avatar
    324 posts

    Posted 29 Sep 2014 Link to this post

    Hello Igorious,

    The RadRibbonView loads only its selected tab content. When you try to find an element in a RadRibbonTab which is not selected (as in your case) the content is not yet loaded and that is why such element can't be found. Also please note that until the ContextualGroup is active the peers for its children (RadRibbonGroup, buttons, e.t.) are not yet created and that is why you can not find the searched element. When you set the IsActive property of the ContextualGroup the RadRibbonView automatically selects the first tab in that group and that is why in this case you can find the element.

    I hope this information helps.

    Kind regards,
    Kiril Vandov
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top