Hello
I would set focus at the same time i set visible a ContextualTabGroup. How can i do that?
Thanks
A contextualtabgroup is not a focusable element. The elements that represent the ContextualTabGroup are dynamically created by the RibbonCaptionPanel.
Thanks for your answer
Exact, i have found a solution with tabitem by adding this on the creation of the pane :
pane.GotFocus += delegate{this.mainRibbon.SelectedTab = this.PersonneTab;};
personneTab is a tabItem.
It works when a control in the pane got the focus, but it will perfect if the event is raised when i select the pane with the mouse or the keyboard.
Yes i have bad explain my problem.
I have some contextualTabgroup whith tabItem.
When i create contentpanel, i set this contextualTabGroup visible like in your samples :
public static readonly DependencyProperty ActivePersonneProperty =DependencyProperty.Register("ActivePersonne",typeof(Personne),typeof(mainWindow),new UIPropertyMetadata(null, OnActivePersonneChanged));
static void OnActivePersonneChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e){mainWindow window = depObj as mainWindow;if (window == null || window.mainRibbon.ContextualTabGroups.Count == 0)return;ContextualTabGroup grp = window.mainRibbon.ContextualTabGroups["PersonneCxtGroup"];grp.IsVisible = window.ActivePersonne != null;}
I can have differents contentpane types whith one contextualTabGroup by type. When i click on a contentpane in the application or when i make ctrl + tab to select it, i want that the tabitem of this contextualtabgroup is selected.
With the code of my previous post, it works but not when i click on the border around the pane or on the tab of the pane.
I'm sorry but I still don't follow what the problem is. Just making a contextualtabgroup visible (which is all the code you listed is doing) does not select a tab from that. You would have to set the SelectedTab property of the XamRibbon to the tab you want to select. If you still have a problem then it would be best if you contact the support group, provide a sample that demonstrates the problem and specific steps on how to reproduce the problem when running the sample so they can look into the issue.
Thanks for your answer Andrew.
I'm Ok with SelectedTab. But my question is a little bit different. For example, I have two different contentPane. When i instanciate the first, I set the property IsVisible of his ContextualTabGroup to true and set the selectedtab of the ribbon to the first tab of this ContextualTabGroup.I instanciate the second and make the same things. Then the selectedTab is now the first tab of the second ContextualTabGroup.If i click on the first pane, or give it focus, i want that the selectedTab become the first of the first ContextualTabGroup.At this time, I use this event of the pane : KeyDown, MouseDown or Focus and it works but not all the time. I need an event which permit this.
Its hard to say from what you have listed but if the contentpanes are documents (i.e. within a DocumentContentHost) then maybe you could use the ActiveDocument property to determine which pane to consider active and therefore which contextual tab group to select. Another option might be to use the ActivePaneChanged and when the ActivePane is non-null then select the tab of the contextualtabgroup associated with the pane.
Many thanks Andrew, with ActivePaneChanged, it's working fine.