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

4 posts, 0 answers
  1. Per
    Per avatar
    4 posts
    Member since:
    Aug 2011

    Posted 27 Jan 2012 Link to this post

    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.
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 01 Feb 2012 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Kathy
    Kathy avatar
    1 posts
    Member since:
    May 2011

    Posted 17 Apr 2012 Link to this post

    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?
  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 19 Apr 2012 Link to this post

    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 >>
Back to Top