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

How do I determine the current docked position of a RadSplitContainer?

3 Answers 340 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Per
Top achievements
Rank 1
Per asked on 27 Jan 2012, 10:40 AM
Hi,

How do I determine the current docked position of a RadSplitContainer?

I have content in a RadPane that I want to format depending on the current docked position of the pane in the RadSplitContainer (for example, a horizontal format when docked to the top or bottom and a vertical format when docked to the left or right and changing the ExpandDirection of expanders to match the current docked position). I've noticed there is a Friend property "State" that seems to contain the current docked position, however this property is not accessible publicly. What is the best way to obtain this information? (A dirty way would be to subclass RadSplitContainer and expose the State property publicly, but it feels like a particularly dirty way to get to this information).

Kind regards,
Dave.

3 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 01 Feb 2012, 12:05 PM
Hello Dave,

In order to get the position of the pane, you have to do the following:
- hook to the PaneStateChange event of the Docking control, which fires every time a pane is moved around. After that get the pane which is not floating.
- using the GetParentSplitContainer method, you could get the SplitContainer in which the current pane is in. You can get the position of that SplitContainer with the RadDocking.GetDockState().
For example:

private void radDocking_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            var pane = e.OriginalSource as RadPane;
            if (pane != null && !pane.IsFloating)
                {
                    var split = pane.GetParentSplitContainer();
                    var pos = RadDocking.GetDockState(split);
                }
            }
        }

Hope this information helps.

Greetings,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Kathy
Top achievements
Rank 1
answered on 17 Apr 2012, 04:52 PM
I have tried the code that you posted and this does not work. No matter where the SplitContainer is docked, it returns DockedLeft when you call GetDockState(). I have seen variations of this code posted in other threads and this bug seems to present itself in each case. Is there any workaround for this?
0
Konstantina
Telerik team
answered on 19 Apr 2012, 01:51 PM
Hi,

The RadDocking.GetDockState() works just fine, but the PaneStateChanged event is called too early and that's why it always returns "DockedLeft". However there is an easy workaround. If you call the GetDockState method into a dispatcher everything will work as expected:

private void Docking_PaneStateChange(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    var pane = e.OriginalSource as RadPane;
    RadSplitContainer container = pane.GetParentSplitContainer();
    Dispatcher.BeginInvoke(new Action(() => {
        var state = RadDocking.GetDockState(container);
    }));
}

Hope this helps.

Kind regards,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
Docking
Asked by
Per
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Kathy
Top achievements
Rank 1
Share this question
or