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

Radpane GotFocus

11 Answers 287 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Jonam
Top achievements
Rank 1
Jonam asked on 15 Aug 2010, 04:41 PM

I want to know which radpane has got the focus. I catch the event GotFocus. This work perfect when the radpanes are tabbed. If i dock the radpane to the left, right or floating then suddenly the window i moved doesn't fire the GotFocus event. This is my code.

<telerik:RadDocking Grid.Row="1" HasDocumentHost="True" HorizontalAlignment="Stretch" Name="radDocking1" VerticalAlignment="Stretch">
    <telerik:RadDocking.DocumentHost>
        <telerik:RadSplitContainer VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
            <telerik:RadPaneGroup x:Name="radPaneGroup" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                <telerik:RadPane x:Name="radPaneAccountlevel6" Header="Hoofdposten" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" GotFocus="radPaneAccountlevel6_GotFocus">
                    <my:AccountLevel5TotalView Grid.Row="1" Name="accountLevel5TotalView1" />
                </telerik:RadPane>
                <telerik:RadPane x:Name="radPaneAccountlevel5" Header="Subposten" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" GotFocus="radPaneAccountlevel5_GotFocus">
                    <TextBlock TextWrapping="Wrap" Text=""></TextBlock>
                </telerik:RadPane>
                <telerik:RadPane x:Name="radPaneAccountlevel4" Header="Accountlevel4" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" GotFocus="radPaneAccountlevel4_GotFocus">
                    <TextBlock TextWrapping="Wrap" Text=""></TextBlock>
                </telerik:RadPane>
                <telerik:RadPane x:Name="radPaneAccountlevel3" Header="Accountlevel3" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" GotFocus="radPaneAccountlevel3_GotFocus">
                    <TextBlock TextWrapping="Wrap" Text=""></TextBlock>
                </telerik:RadPane>
                <telerik:RadPane x:Name="radPaneAccountlevel2" Header="Accountlevel2" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" GotFocus="radPaneAccountlevel2_GotFocus">
                    <TextBlock TextWrapping="Wrap" Text=""></TextBlock>
                </telerik:RadPane>
                <telerik:RadPane x:Name="radPaneAccountlevel1" Header="Accountlevel1" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" GotFocus="radPaneAccountlevel1_GotFocus">
                    <TextBlock TextWrapping="Wrap" Text=""></TextBlock>
                      
                </telerik:RadPane>
                <telerik:RadPane x:Name="radPaneContract" Header="Opdrachten" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" GotFocus="radPaneContract_GotFocus">
                    <TextBlock TextWrapping="Wrap" Text=""></TextBlock>
                </telerik:RadPane>
                <telerik:RadPane x:Name="radPaneBill" Header="Facturen" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" GotFocus="radPaneBill_GotFocus">
                    <TextBlock TextWrapping="Wrap" Text=""></TextBlock>
                </telerik:RadPane>
            </telerik:RadPaneGroup>
        </telerik:RadSplitContainer>
    </telerik:RadDocking.DocumentHost>
</telerik:RadDocking>

Is this their a work around to this problem?

kind regards,

Jonam

11 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 18 Aug 2010, 02:22 PM
Hello Jonam,

Thank you for contacting us.

When you dock a pane outside the initial RadPaneGroup where it is generated, this pane is placed in a new created RadSplitContainer and a new RadPaneGroup. If you make it floating, a ToolWindow is generated and the content for this RadPane plus a new RadPaneGroup and RadSplitContainer are placed in this ToolWindow. This is how RadDocking works. In this circumstances you lose GotFocus event handler. If you want to get focused the content in RadPane when it goes floating, you could handle GotFocus event of the ToolWindow.

Could you give us some more details what is your scenario and why do you need to handle GotFocus event for each RadPane

I hope this information helps. I will be glad to assist you further.

Best wishes,
George
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Jonam
Top achievements
Rank 1
answered on 19 Aug 2010, 11:42 AM
Hello George,

thank you for responding and explaning the event and process cycle of docking. The scenario in which i need to handle GotFocus event for each RadPane is the following.

I want to know which RadPane is last selected so i can display a context senstive menu in the ribbonbar. But if the got focus event suddenly doesn't respond any more because it is in a toolwindow then i context menu doesn't matches the active window.

Do you know the solution to this problem?

kind regards,

Jonam
0
Jonam
Top achievements
Rank 1
answered on 19 Aug 2010, 12:37 PM
Got a part of  the solution. Catch the LayoutChangeStarted off the radDocking and find the active radpane with the following statements. But after i click on a tabbed control and then the toolwindow i get no event. How do i get a reference to the toolwindow?

 

 

 

 

 

List<RadPane> list = radDocking1.Panes.ToList();
list = list.Where(x => x.IsSelected && x.IsFocused ).ToList();
0
Accepted
George
Telerik team
answered on 19 Aug 2010, 04:05 PM
Hello Jonam,

That's a right approach to get the latest selected RadPane.

You need to handle GotFocus event for the ToolWindow when a pane goes floating. You could do this using PaneStateChange event. It fires when a RadPane changes its state. For example:

private void RadDocking_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadPane pane = e.Source as RadPane;
            if (pane != null && pane.IsFloating)
            {
                ToolWindow toolWindow = pane.ParentOfType<ToolWindow>();
                if (toolWindow == null)
                {
                    toolWindow = (((pane.Parent as RadPaneGroup).Parent as RadSplitContainer).Parent) as ToolWindow;
                    if (toolWindow != null)
                    {
                        toolWindow.GotFocus += new RoutedEventHandler(toolWindow_GotFocus);
                    }
                }
                else
                {
                    toolWindow.GotFocus += new RoutedEventHandler(toolWindow_GotFocus);
                }
            }
        }
 
There is a bug in the framework when you make RadPane floating via the ContextMenu - ParentOfType<ToolWindow> returns null in these circumstances. That's why you could get the ToolWindow using Parent property. When you found it, you could handle GotFocus event and it will fires everything when this ToolWindow gets focused. I suggest you to detach GotFocus event handler when the ToolWindow is closing.

I hope this helps! I will be glad to assist you further.

Kind regards,
George
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Jonam
Top achievements
Rank 1
answered on 20 Aug 2010, 07:43 PM
Thank you george this works almost 100%. I have now only a minor issue. What if the user drags a pane into a toolwindow. Next they drag another pane to dock into this toolwindow? I tried the code below but this doesn't work. How to realize this final step? p.s.  if i don't detach the gotFocus event handler isn't this disposed in the garbage collection?


void toolWindow_GotFocus(object sender, RoutedEventArgs e)
{
    ToolWindow window = (ToolWindow)sender;
      
    RadSplitContainer container = (RadSplitContainer)window.Content;
    if (container != null)
    {
        foreach (RadPaneGroup group in container.Items)
        {
            foreach (RadPane pane in group.Items)
            {
                if (pane.IsSelected)
                    ActiveWindow = GetWindowConstantFromPaneName(pane.Name);
            }
        }
    }
    groupRefresh.Header = ActiveWindow;
}
0
George
Telerik team
answered on 25 Aug 2010, 02:14 PM
Hi Jonam,

Could you please describe the problem in details. What do you mean by saying "doesn't work"?
GC collects only objects in the managed heap that are no longer being used by the application. I suggest you to detach the event handler manually.
 
Looking forward to your reply.

Sincerely yours,
George
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
kyle
Top achievements
Rank 1
answered on 11 Nov 2010, 04:53 AM
Hi,

When a pane is unpinned, hover over it to expand the pane,then click the pane ,it's can't got focus.
0
Uli
Top achievements
Rank 1
answered on 30 Nov 2010, 09:02 AM
Hi Jonam,

I have the same problem, but I can't get it work.
Do you have a working example?
0
Jurjen Ladenius
Top achievements
Rank 2
answered on 04 Mar 2011, 05:05 PM
I'm in exactly the same situation. Would be good if Telerik provided an example... 
0
Kais
Top achievements
Rank 1
answered on 07 Mar 2011, 09:29 PM
Hi all, 

Very interested in RadPane focus also, for context sensitive toolbars/options. The solution I have taken is to handle DockManager.PreviewMouseUp, and manually set "focus" (as a property on my component view models) to true for the item that was clicked. This is "good enough" for my app. Means if the user clicks on a component (ie: control inside a radpane), or on the radpane itself, I can set which is focused. Here's my code:

private void DockManager_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            RadPane pane = null;
                 
            if (e.Source is RadPaneGroup)
            {
                pane = ((RadPaneGroup)e.Source).EnumeratePanes().FirstOrDefault(x => x.IsSelected);               
            }
            else if (e.Source is RadComponentPane)
            {
                pane = (RadPane)e.Source;
            }
 
            // Focus the clicked pane       
            if (pane != null)
            {
                var component = pane.Content as ComponentViewModelBase;
                if (component != null)
                    component.IsFocusedComponent = true;
            }
        }

This works fine for RadPane's docked as documents. I havent tested it elsewhere. 

I also have a oneway binding from RadPane.IsSelected to my view model (COmponentViewModelBase) IsFocusedcomponent property to handle some spurious cases. 

Yes ActivePane / ActivePaneChanged event would be a great feature Telerik! Hope to see this at some point. 

Best regards, 
0
Patrick
Top achievements
Rank 1
answered on 08 Mar 2011, 03:16 AM
Tags
Docking
Asked by
Jonam
Top achievements
Rank 1
Answers by
George
Telerik team
Jonam
Top achievements
Rank 1
kyle
Top achievements
Rank 1
Uli
Top achievements
Rank 1
Jurjen Ladenius
Top achievements
Rank 2
Kais
Top achievements
Rank 1
Patrick
Top achievements
Rank 1
Share this question
or