Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1240
Determining if ToggleDockedState will toggle
posted

I want to add a button that will toggle the docked state on a pane from floating to docked, and vice versa.  This button needs to be disabled if the ToggleDockedState can’t toggle the docked state.  An example of this would be a new window that starts out floating and does not have a previous dock location.  In this case, ToggleDockedState does not do anything. Conversely, if the new window is part of a layout, it has this information so ToggledDockState will toggle.  How can I determine if ToggleDockedState can actually toggle.  I’ve looked at numerous properties in the dock manager, but I cannot find the one that will tell me this.

Thanks

Dan

Parents
  • 34810
    Offline posted

    Hello Dan,

    I have been investigating into this behavior that you are looking to achieve, and there does not currently exist a property or method on the XamDockManager or the ContentPane that is publically exposed that determines whether or not a particular pane can toggle its docked state. This is completely determined internal to the XamDockManager, and as such, the simplest way to determine whether or not your toggle button should be enabled or not would likely be to keep track of the state of your panes and set a flag once one has been docked or its state has actually been changed. Unfortunately, there are no events that fire that can allow you to keep track of the PaneLocation property and when it changes, but you can implement this using the techniques described here.

    With the above said, there is an internal method that could help you to determine the "toggle docked state" ability of the ContentPane. This method is called ToggleDockedStateImpl and it exists on the XamDockManager and it takes a ContentPane as a parameter. You can grab it using reflection, but it's not exactly recommended. This method has a bool return type, and if it returns true, it will toggle the docked state of your pane. If it returns false, however, this means the dock state is not currently able to be toggled. You can invoke this method like so, where "pane1" is a ContentPane and "dockManager" is the XamDockManager:

    MethodInfo info = dockManager.GetType().GetMethod("ToggleDockedStateImpl", BindingFlags.NonPublic | BindingFlags.Instance);
    object[] para = new object[] { pane1 };
    bool b = (bool)info.Invoke(dockManager, para);

    Please let me know if you have any other questions or concerns on this matter.

Reply Children
No Data