简体   繁体   中英

make dock left or right for a document panel with devexpress wpf

I am dynamically adding documentpanel to document group in docklayoutmanager manager and all of them contains user controls inside them. Now, I have docked all somewhere or the other, but except two of the document panel that contains some kind of charts, none of them could move out. Basically, they both are docked beside each other, and they can float and also dock back to their regular place. But how to make it dock only to left or right, but not top bottom or tabbed.

this is how I am creating dynamically those panels:

private void History()
        {
            string guid = System.Guid.NewGuid().ToString("N");
            while (char.IsDigit(guid[0]))
                guid = System.Guid.NewGuid().ToString("N");

            HistoryViewModel historyViewModel = new HistoryViewModel
            {
                Caption = "History",
                MinWidth = 300,
                MinHeight = 200,
                ViewName = "History",
                HistoryImage = layoutFilePath.calenderImage,
                BindableName = guid,
                CanDrag = true,
                CanDock = true,
                CanFloat = true
            };
            ((IMVVMDockingProperties)historyViewModel).TargetName = "PanelHost";
            WidgetList.Add(historyViewModel);
        }

History View model is nothing but a view model to fetch from that user control.

Thanx in advance for your help!

In your DockLayoutManager you can use DockLayoutManager.DockItemDocking event. Just check for the DockItemDockingEventArgs.DockType property. If it not equals to DockType.Left or to DockType.Right then set the DockItemDockingEventArgs.Cancel property to false .
Here is example:

private void DockLayoutManager_DockItemDocking(object sender, DockItemDockingEventArgs e)
{
    e.Cancel = e.DockType != DockType.Left && e.DockType != DockType.Right;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM