4 Answers, 1 is accepted
0
Hello Steffen,
Nikolay
the Telerik team
RadDock has his own drag and drop mechanisms that determine the drag and drop behavior within the control itself. However, this architecture does not allow for implementing the scenario that you have where something outside RadDock would cause the activation of a window on DragEnter.
Let us know if you have other questions.
Nikolay
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more.
Check out all of the latest highlights.
0
scottw
Top achievements
Rank 1
answered on 21 May 2014, 06:52 PM
Am I to take it that this means it is 100% impossible to do this? Is there any kind of a work around? This doesn't seem like a far-fetched scenario. My scenario is dragging a data item within the application to any one of several open dock windows. I simply want to activate the window (bring it to the front) when the item is dragged over the tab strip item for that window.
0
scottw
Top achievements
Rank 1
answered on 21 May 2014, 07:11 PM
Actually, I found a work around that seems to work. It involves using the Dock's DockTabStripNeeded and the DockTabStrips's DragOver events.
Firstly, use DockTabStripNeeded to attach the DragOver event handler to any tab strips created by the dock
void rdMainDock_DockTabStripNeeded(object sender, DockTabStripNeededEventArgs e)
{
DockTabStrip strip;
if (e.DockType == DockType.Document)
strip = new DocumentTabStrip();
else
strip = new ToolTabStrip();
strip.AllowDrop = true;
strip.DragOver += DockTabStrip_DragOver;
e.Strip = strip;
}
then in the DragOver event, loop through the TabStripItems until you find the one that contains the pointer's X and Y coordinates and find the associated DockWindow by the text property. This assumes that your windows / tabs have unique text.
void DockTabStrip_DragOver(object sender, DragEventArgs e)
{
DockTabStrip strip = sender as DockTabStrip;
if (strip != null)
{
foreach(TabStripItem tab in strip.TabStripElement.Items)
{
if (tab.RectangleToScreen(tab.Bounds).Contains(new Point(e.X, e.Y)))
{
DockWindow dragOverWindow = rdMainDock.DockWindows.FirstOrDefault(w => w.Text == tab.Text);
if (dragOverWindow != null && dragOverWindow != rdMainDock.ActiveWindow)
rdMainDock.ActivateWindow(dragOverWindow);
}
}
}
}
This seems a little hacky, in particular, finding the window based on the text. I'd love to see the Telerik guys provide a better way to do this that's cleaner, but this works and will activate ToolWindows or DockWindows the same.
gvAvailableFields.GridBehavior = new NoWrapGridBehavior();
gvSelectedFields.GridBehavior = new NoWrapGridBehavior();
gvAvailableFields.GridBehavior = new NoWrapGridBehavior();
gvSelectedFields.GridBehavior = new NoWrapGridBehavior();
gvAvailableFields.GridBehavior = new NoWrapGridBehavior();
gvSelectedFields.GridBehavior = new NoWrapGridBehavior();
Firstly, use DockTabStripNeeded to attach the DragOver event handler to any tab strips created by the dock
void rdMainDock_DockTabStripNeeded(object sender, DockTabStripNeededEventArgs e)
{
DockTabStrip strip;
if (e.DockType == DockType.Document)
strip = new DocumentTabStrip();
else
strip = new ToolTabStrip();
strip.AllowDrop = true;
strip.DragOver += DockTabStrip_DragOver;
e.Strip = strip;
}
then in the DragOver event, loop through the TabStripItems until you find the one that contains the pointer's X and Y coordinates and find the associated DockWindow by the text property. This assumes that your windows / tabs have unique text.
void DockTabStrip_DragOver(object sender, DragEventArgs e)
{
DockTabStrip strip = sender as DockTabStrip;
if (strip != null)
{
foreach(TabStripItem tab in strip.TabStripElement.Items)
{
if (tab.RectangleToScreen(tab.Bounds).Contains(new Point(e.X, e.Y)))
{
DockWindow dragOverWindow = rdMainDock.DockWindows.FirstOrDefault(w => w.Text == tab.Text);
if (dragOverWindow != null && dragOverWindow != rdMainDock.ActiveWindow)
rdMainDock.ActivateWindow(dragOverWindow);
}
}
}
}
This seems a little hacky, in particular, finding the window based on the text. I'd love to see the Telerik guys provide a better way to do this that's cleaner, but this works and will activate ToolWindows or DockWindows the same.
gvAvailableFields.GridBehavior = new NoWrapGridBehavior();
gvSelectedFields.GridBehavior = new NoWrapGridBehavior();
gvAvailableFields.GridBehavior = new NoWrapGridBehavior();
gvSelectedFields.GridBehavior = new NoWrapGridBehavior();
gvAvailableFields.GridBehavior = new NoWrapGridBehavior();
gvSelectedFields.GridBehavior = new NoWrapGridBehavior();
0
Hello Scott,
Thank you for replying.
I am glad that you have found a way to activate a window according to your requirements, also the solution seems perfectly fine.
Do not hesitate to let us know, should you have any questions.
Regards,
George
Telerik
Thank you for replying.
I am glad that you have found a way to activate a window according to your requirements, also the solution seems perfectly fine.
Do not hesitate to let us know, should you have any questions.
Regards,
George
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.