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

How to know the active control within XAML designer?

2 Answers 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 14 May 2015, 02:06 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Vandov
Telerik team
answered on 18 May 2015, 01:54 PM
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
0
Mike
Top achievements
Rank 1
answered on 18 May 2015, 03:31 PM
That helps immensely.  It's a lot better start than the blind trial-and-error I've been trying.  Thanks very much!
Tags
General Discussions
Asked by
Mike
Top achievements
Rank 1
Answers by
Kiril Vandov
Telerik team
Mike
Top achievements
Rank 1
Share this question
or