查看了下MSDN发现Popup没有类拟Drag相关的属性和方法,第一时间想了thumb。忙了一会未果,就想起了强大的google。

发现中文资料很少,英文的发现有两篇很不错的,所以笔记在博客园里,希望对园里的朋友有用。

social.msdm

stackoverflow

楼主推荐使用social.msdm的方法,试过很好用:

<Popup Name="puSkills" Placement="MousePoint" PopupAnimation="Scroll" AllowsTransparency="True" IsEnabled="True" IsOpen="False">
<Border BorderBrush="DarkCyan" BorderThickness="3">
<StackPanel Background="AliceBlue" VerticalAlignment="Center" Height="400" Width="400">
<Label Name="lblCaption" FontWeight="Bold" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="Blue" Background="Blue" MouseLeftButtonDown="lblCaption_MouseLeftButtonDown">Move</Label>
<StackPanel> <TextBlock HorizontalAlignment="Right">
Some Contents...........
</TextBlock>
</StackPanel>
</StackPanel>
</Border>
</Popup>

后台CS代码:

 [DllImport("user32.dll")]
public static extern IntPtr WindowFromPoint(POINT Point); [DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCursorPos(out POINT lpPoint); [DllImportAttribute("user32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); [DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture(); [StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
public int Y;
} public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2; private void lblCaption_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
POINT curPos;
IntPtr hWndPopup; GetCursorPos(out curPos);
hWndPopup = WindowFromPoint(curPos); ReleaseCapture();
SendMessage(hWndPopup, WM_NCLBUTTONDOWN, new IntPtr(HT_CAPTION), IntPtr.Zero);
}

Click the Move Content in label.. then move the mouse. Thank you!

最新文章

  1. Intellij idea 和android studio 代码给混淆
  2. GOLANG SDK下载
  3. VS中Qt的探索02
  4. 深入浅出设计模式——解释器模式(Interpreter Pattern)
  5. 调用存储过程从EntityFramework
  6. zzuli oj 1165 实数的小数部分(指针专题)
  7. Struts2 文件的上传与下载
  8. C语言初学 俩数相除问题
  9. 去确认CP210x UART Bridge的USB的VID和PID
  10. Callable 获取线程返回值
  11. opencv在arm和x86在移植
  12. VS调试的简单技巧
  13. [kuangbin带你飞]专题四 最短路练习 POJ 2253 Frogger
  14. qt实现一个简单的计算器
  15. mysql常用脚本及命令记录
  16. sql server 锁与事务拨云见日(下)
  17. Angular学习第一步
  18. Makefile依赖关系中的竖线“|”
  19. Node的关系型数据库ORM库:bookshelf
  20. PAT甲题题解-1029. Median (25)-求两序列的中位数,题目更新了之后不水了

热门文章

  1. OpenCV编译步骤
  2. ag
  3. ios开发视频播放后台下载功能实现 :1,ios播放视频 ,包含基于AVPlayer播放器,2,实现下载,iOS后台下载(多任务同时下载,单任务下载,下载进度,下载百分比,文件大小,下载状态)(真机调试功能正常)
  4. [TypeScript] Using ES6 and ESNext with TypeScript
  5. iOS 取消多余tableView的横线的写法
  6. java开发环境配置(windows下JDK7+tomcat7)
  7. Azure Messaging-ServiceBus Messaging
  8. SWFTools PDF转换为SWF
  9. 将 WPF、UWP 以及其他各种类型的旧 csproj 迁移成基于 Microsoft.NET.Sdk 的新 csproj
  10. rabbitmq集群 + Mirror Queue + 使用C#