So I am working with WPF Infragistics XamDockManager
and PaneToolWindow
.
I am restyling the chrome of the PaneToolWindow
with a custom XamRibbonWindow
.
I have managed to do this successfully. When this is done though the PaneToolWindow
loses it's ability to be drug around.
The solution is to reimplement the dragging functionality (Both my assessment and also the recommendation from Infragistics). However, unfortunately for me, and all users of the Infragistics WPF toolkit, there is almost zero documentation and examples of how to do this. The one example that infragistics does provide is buggy to say the least.
The setup:
This is my custom Dock Manager
public class CustomDockManager : XamDockManager
{
protected override PaneToolWindow CreatePaneToolWindow()
{
return new CustomPaneToolWindow() as PaneToolWindow;
}
}
This is my custom PaneToolWindow
public class CustomPaneToolWindow : PaneToolWindow
{
private Point _MouseClickPoint { get; set; }
private Boolean _IsMouseDown { get; set; }
public CustomPaneToolWindow()
{
this.MouseLeftButtonDown += CustomPaneToolWindow_MouseLeftButtonDown;
}
private void CustomPaneToolWindow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this._IsMouseDown = true;
this._MouseClickPoint = e.GetPosition(this as UIElement);
}
else
{
this._IsMouseDown = false;
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
//Need to move the window around here.
}
}
Now I tried simple and moved to complex.
First, I tried just doing something like this.
public Window _WindowOfCustomToolPaneWindow { get { return Window.GetWindow(this); } }
public CustomPaneToolWindow()
{
this._WindowOfCustomToolPaneWindow.MouseLeftButtonDown
+=CustomPaneToolWindow_MouseLeftButtonDown;
}
private void CustomPaneToolWindow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this._WindowOfCustomToolPaneWindow.DragMove();
}
You would think that this returns the window that is floating around and contains this
right? You'd be wrong. In fact it returns the parent window. This causes the DragMove()
call to send the child window flying off the screen.
So on to the next...
protected override void OnMouseMove(MouseEventArgs e)
{
Point cachedPoint = e.GetPosition(this as UIElement);
if (this._IsMouseDown && cachedPoint != this._MouseClickPoint)
{
Vector delta = Point.Subtract(this._MouseClickPoint, cachedPoint);
this.Left -= delta.X;
this.Top -= delta.Y;
this._MouseClickPoint = cachedPoint;
this._IsMouseDown = false;
}
}
This is a little more verbosely attempting to move the window around. Unfortunately it doesn't work either. I think it's adjusting the margins of the UserControl inside the window instead of moving the window itself.
I'm at a bit of a loss. The lack of support from Infragistics on the topic is disturbing to say the least.
Does anyone have any ideas on how to resolve this?
See Question&Answers more detail:
os