Infragistics PaneToolWindow窗口DragMove - 诡异的结果

时间:2015-07-13 15:14:24

标签: c# wpf infragistics

所以我正在使用WPF Infragistics XamDockManagerPaneToolWindow

我正在使用自定义PaneToolWindow重新定位XamRibbonWindow的镶边。

I have managed to do this successfully.虽然PaneToolWindow失去了吸毒能力,但仍然可以做到这一点。

解决方案是重新实现拖动功能(我的评估和recommendation from Infragistics)。但是,遗憾的是,对于我和Infragistics WPF工具包的所有用户,几乎没有文档和如何执行此操作的示例。信息完全提供的一个例子至少可以说是错误的。

设置:

这是我的自定义Dock Manager

public class CustomDockManager : XamDockManager
{
   protected override PaneToolWindow CreatePaneToolWindow()
   {
      return new CustomPaneToolWindow() as PaneToolWindow;
   }
}

这是我自定义的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.
    }
  }

现在我尝试了简单的移动来复杂化。

首先,我尝试过做这样的事情。

  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();
  }

您会认为这会返回浮动的窗口并包含this吗?你错了。实际上它返回父窗口。这会导致DragMove()调用将子窗口从屏幕上移开。

接下来......

 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;
    }
  }

这更加冗长地试图移动窗户。不幸的是,它也没有用。我认为它调整了窗口内UserControl的边距而不是移动窗口本身。

我有点失落。至少可以说,Infragistics对该主题缺乏支持是令人不安的。

有没有人对如何解决这个问题有任何想法?

1 个答案:

答案 0 :(得分:1)

PaneToolWindow拖动事件的内部,Infragistics正在寻找名为“PART_Caption”的UIElement

通过在我的XamRibbonWindow周围添加边框并为其提供x:Name="PART_Caption",它解决了问题。

  <Style TargetType="{x:Type igDock:PaneToolWindow}" x:Key="DockPTW">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type igDock:PaneToolWindow}">
                    <Border x:Name="PART_Caption" BorderThickness="4" Background="Red">
                    <igRibbon:RibbonWindowContentHost>

                        <igRibbon:RibbonWindowContentHost.Ribbon>
                            <igRibbon:XamRibbon x:Name="MAIN_RIBBON" DockPanel.Dock="Top">

                            </igRibbon:XamRibbon>
                        </igRibbon:RibbonWindowContentHost.Ribbon>
                        <Grid Width="1000" Height="500">


                        </Grid>
                    </igRibbon:RibbonWindowContentHost>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>