How to know the active control within XAML designer?

3 posts, 1 answers
  1. Mike
    Mike avatar
    6 posts
    Member since:
    Sep 2012

    Posted 14 May 2015 Link to this post

    How to know, during design-time, which control is active / focused by the user in a custom items control, so as to show the rendering for that selected item?

     

    I'm after functionality similar to TabControl.  The difference in my control is that it displays a very simple, sequential workflow, with transitions in between, and will show breadcrumbs in place of tabs.  I've tried extended the TabControl, but haven't gotten anything that works. Currently, I'm just displaying the first panel content of the control. I need to know when a developer has another panel active in the XAML editor to display content of that panel, accordingly.

     

    I'm currently after a value that would be available in MeasureOverride, but would be flexible as long as I have anything available in the code-behind.I've tried such hacks as

    if (System.ComponentModel.DesignerProperties.IsInDesignTool)
    {
        foreach (var panel in this.Panels)
        {
            panel.GotFocus += focusHandler;
        }
    }
    and using
    System.Windows.Input.FocusManager.GetFocusedElement()
    but haven't met with any luck thus far.

     

    The TabControl is obviously aware of which element is active at design-time.  How is that known?  Or, is there a styling I could apply to the TabControl that would change tabs to breadcrumbs and allow a transition between tab contents?

  2. Answer
    Kiril Vandov
    Admin
    Kiril Vandov avatar
    324 posts

    Posted 18 May 2015 Link to this post

    Hello Mike,

    The entire design time logic of all controls is separated in a different assembly (a design time assembly). These assemblies are generated via a DesignTime project which is shipped with our SourceCode and you could take a loot at the DesignTime implementation of the RadTabControl (Telerik_UI_for_Silverlight_Source\Controls\Navigation\Design). Making design time project for your control will allow you to plug in such custom logic and controls visible only in the designer for your custom control. You could take a look at this article describing how you could debug/create design time project.
    Kind regards. Another useful article is the one for the feature providers and feature connectors used to link the design time logic and the control.

    The RadTabControl knows its selection as it its DesignTime project has a feature which derives from "SelectedDesignModeValueProvider" which controls such selection logic.
    As for your other question "Or, is there a styling I could apply to the TabControl that would change tabs to breadcrumbs and allow a transition between tab contents?" I am not sure that I understand you correctly as I do not have enough information about the control and the desired design-time behavior.

    I hope this information helps

    Kiril Vandov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
  4. Mike
    Mike avatar
    6 posts
    Member since:
    Sep 2012

    Posted 18 May 2015 in reply to Kiril Vandov Link to this post

    That helps immensely.  It's a lot better start than the blind trial-and-error I've been trying.  Thanks very much!
Back to Top