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

How to rise event for dock/orientation change?

10 Answers 248 Views
Docking
This is a migrated thread and some comments may be shown as answers.
RoxanaC
Top achievements
Rank 1
RoxanaC asked on 14 Jan 2010, 09:29 AM
Hello!
I need an event for changing the docking orientation of a RadPane.
The purpose of it is that I need to have a layout if the RadPane is docked left or right and a different layout if it is docked on top or bottom, and I want to rearrange it (or at least change the orientation of the content)  whenever the user feels to modify the position of the pane.
How can I achieve this?

Thank you!
Roxana

10 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 15 Jan 2010, 08:55 AM
Hi Roxana ,

You could use the PaneStateChanged event of the Docking control - it is raised whenever a RadPane changes its state. Please refer to the following sample code (the RadDocking_PaneStateChanged method is an event handler for the PaneStateChanged event):
private void RadDocking_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    var pane = e.OriginalSource as RadPane;
    pane.Dispatcher.BeginInvoke(() => pane.Content = FindPanePosition(pane));
}
 
private static DockState? FindPanePosition(RadPane pane)
{
    if (pane.IsFloating)
    {
        return pane.IsDockable ? DockState.FloatingDockable : DockState.FloatingOnly;
    }
 
    var p = pane.Parent as ISplitItem;
 
    if (p == null)
    {
        // The pane is in AutoHideArea
        return null;
    }
 
    var container = p.ParentContainer;
    while (container != null)
    {
        p = container;
        container = p.ParentContainer;
    }
 
    container = p as RadSplitContainer;
    return RadDocking.GetDockState(container);
}

Hope this helps.

Greetings,
Miroslav Nedyalkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
RoxanaC
Top achievements
Rank 1
answered on 15 Jan 2010, 11:31 AM
It's true, the PaneStateChange event was the answer to my question, thank you!
But the RadDocking.GetDockState(container) method always returns the same value equal with the InitialPosition no matter where the container is docked.
0
RoxanaC
Top achievements
Rank 1
answered on 15 Jan 2010, 12:07 PM
Actually after more debug I found out that theRadDocking.GetDockState(container) method always returns the same value equal with the DockedLeft no matter where the container is docked OR the InitialPosition
0
Miroslav Nedyalkov
Telerik team
answered on 18 Jan 2010, 10:10 AM
Hi Roxana Cocariu,

 The RadDocking.GetDockState method gets the value of the RadDocking.DockStateProperty attached property of the provided dependency object. In order to find its actual placement you should get the value of this property from the root-most split container. Please refer to the FindPanePosition method I sent in the previous post.

Kind regards,
Miroslav Nedyalkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
RoxanaC
Top achievements
Rank 1
answered on 19 Jan 2010, 07:33 AM
Yes, I am referring to the FindPanePosition method and if the pane is not floating, the result is always the same
(DockedLeft )
Roxana
0
Miroslav Nedyalkov
Telerik team
answered on 20 Jan 2010, 12:42 PM
Hello Roxana,

 I think I cannot clearly understand what you need. The code I sent you works just fine at my side - could you please send me a screen-shot or video what is wrong and how you think it should be - this should help me better understand what you need.

Best wishes,
Miroslav Nedyalkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
RoxanaC
Top achievements
Rank 1
answered on 25 Jan 2010, 08:28 AM
Hey! Try to check this out!

<Window x:Class="DockStateFinder.Window1" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
        xmlns:telerikDock="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking" 
        Title="Window1"
    <Grid > 
        <telerikDock:RadDocking x:Name="radDocking" 
                                PaneStateChange="RadDocking_PaneStateChange"
            <telerikDock:RadDocking.DocumentHost> 
                <telerik:RadSplitContainer> 
                    <telerik:RadPaneGroup> 
                        <telerik:RadDocumentPane Title="Description"
                            <telerik:RadDocumentPane.Content> 
                                <TextBlock TextWrapping="Wrap" 
                                           Text="On the Documents tab above press Ctrl + Mouse Left button to display the Popup Menu. You can use the same combination on every tab." /> 
                            </telerik:RadDocumentPane.Content> 
                        </telerik:RadDocumentPane> 
                        <telerik:RadPane Header="NotDragable" 
                                         CanFloat="False"
                            <telerik:RadPane.Content> 
                                <TextBlock TextWrapping="Wrap" 
                                           Text="This pane cannot be dragged, because it has its property CanFloat set 'False'." /> 
                            </telerik:RadPane.Content> 
                        </telerik:RadPane> 
                    </telerik:RadPaneGroup> 
                </telerik:RadSplitContainer> 
 
            </telerikDock:RadDocking.DocumentHost> 
 
            <telerikDock:RadSplitContainer x:Name="rsp1" 
                                           Orientation="Vertical" 
                                           InitialPosition="DockedRight"
                <telerikDock:RadPaneGroup x:Name="rpgInitRightGroup"
                    <telerikDock:RadPane x:Name="rpInitRight" 
                                         Header="InitialPosition Right"
                        <TextBlock>some content here</TextBlock> 
                    </telerikDock:RadPane> 
                </telerikDock:RadPaneGroup> 
            </telerikDock:RadSplitContainer> 
 
            <telerikDock:RadSplitContainer x:Name="rspLeft" 
                                           Orientation="Vertical" 
                                           InitialPosition="DockedLeft"
                <telerikDock:RadPaneGroup x:Name="rpgInitLeftGroup"
                    <telerikDock:RadPane x:Name="rpInitLeft" 
                                         Header="InitialPosition Left"
                        <TextBlock>some other content here</TextBlock></telerikDock:RadPane> 
                </telerikDock:RadPaneGroup> 
            </telerikDock:RadSplitContainer> 
        </telerikDock:RadDocking> 
    </Grid> 
</Window> 
 
 

and the code behind:

using System.Diagnostics; 
using System.Windows; 
 
using Telerik.Windows.Controls; 
using Telerik.Windows.Controls.Docking; 
 
namespace DockStateFinder { 
    /// <summary> 
    /// Interaction logic for Window1.xaml 
    /// </summary> 
    public partial class Window1 : Window { 
        public Window1() { 
            InitializeComponent(); 
        } 
 
        private static DockState? FindPanePosition( RadPane pane ) { 
            if (pane.IsFloating) { 
                return pane.IsDockable ? DockState.FloatingDockable : DockState.FloatingOnly; 
            } 
 
            var p = pane.Parent as ISplitItem; 
 
            if (p == null) { 
                // The pane is in AutoHideArea 
                return null
            } 
 
            var container = p.ParentContainer; 
            while (container != null) { 
                p = container; 
                container = p.ParentContainer; 
            } 
 
            container = p as RadSplitContainer; 
            return RadDocking.GetDockState( container ); 
        } 
 
        private void RadDocking_PaneStateChange( object sender, Telerik.Windows.RadRoutedEventArgs e ) { 
            var pane = e.OriginalSource as RadPane; 
            //pane.Dispatcher.BeginInvoke( pane.Content = FindPanePosition( pane ) ); 
            DockState ds = (DockState)FindPanePosition( pane ); 
 
            Trace.WriteLine( "Dock state => " + ds ); 
        } 
    } 
 


Every time you change the docking position of the left or right pane (move they to either top, bottom, left, right) in the output will be printed the same value "Dock state => DockedLeft" ( and Dock state => FloatingDockable if the pane is not docked on any position). I need somehow to retrieve DockedBottom if I move it to the bottom of the RadDocking and so on for different positions

I hope I was more clear this time.
Thx! Roxana
0
Kaloyan
Telerik team
answered on 28 Jan 2010, 12:18 PM
Hello Roxana Cocariu,

Sorry for the late response. Actually we have found an issue concerning this type of RadDocking functionality. We are working on its resolving, and hopefully it will be ready for the Q1 2010 official release.

Regards,
Kaloyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Lee
Top achievements
Rank 1
answered on 08 Sep 2010, 10:17 AM
Hi,

I am experiencing the same behaviour as described above (code always returns DockedLeft). Has this been resolved? Is there a different method to use now? I'm using RadControls WPF Q2 2010 SP1.

Thanks,
Lee

EDIT: I found another post that had the same code but that was invoking the call to FindPanePosition through the Dispatcher - and this makes all the difference.
0
Kaloyan
Telerik team
answered on 10 Sep 2010, 08:31 AM
Hello Lee,

In the loaded event handler use the following code:

var position = radPane.ParentOfType<RadSplitContainer>().InitialPosition;

All the best,
Kaloyan
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
Tags
Docking
Asked by
RoxanaC
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
RoxanaC
Top achievements
Rank 1
Kaloyan
Telerik team
Lee
Top achievements
Rank 1
Share this question
or