请问WPF在Blend 4中怎么实现对无边框的窗体拖动。会请详细点哦…
wpf吧
全部回复
仅看楼主
level 4
wendygeo 楼主
单单一个图片之类的我已经可以实现拖动了。。。我制作了一个界面实现了3D旋转(双击下旋转到另一个界面去),但现在就是有一个问题,它居然实现不了窗体界面拖动了,我也用了这个代码MouseDown(object sender, MouseButtonEventArgs e)
{ if (e.LeftButton == MouseButtonState.Pressed),是不是因为弄了一个3D旋转界面,所以不能拖动了?请帮我找到解决的关键。。。
2012年07月25日 13点07分 1
level 5
添加鼠标左键单机事件,e.dragmove();
2012年07月25日 15点07分 2
level 5
添加鼠标左键单机事件,e.dragmove();
2012年07月25日 15点07分 3
level 5
添加鼠标左键单机事件,e.dragmove();
2012年07月25日 15点07分 4
level 5
添加鼠标左键单机事件,e.dragmove();
2012年07月25日 15点07分 5
这个我也有写进去。。。不是这个问题
2012年07月25日 15点07分
回复@wendygeo :你去掉你的双击事件或把拖动变成右键单击试试
2012年07月25日 16点07分
@小小已然 我用了右击运行后显示错误啊,,,未处理的异常: System.InvalidOperationException: 只能在按下主鼠标按钮时调用 DragMove。 在 System.Windows.Window.DragMove()。。。
2012年07月26日 01点07分
level 5
好像还的设置一个属性允许它能拖动
2012年07月25日 15点07分 6
level 4
wendygeo 楼主
我使用了右击,显示了错误。。生成项目: Mainwin.sln,目标: Build
__________________________________________________
项目“C:\Users\user\Desktop\Mainwin - 副本\Mainwin.sln”(Build 个目标): __________________________________________________
项目“C:\Users\user\Desktop\Mainwin - 副本\Mainwin.sln”正在生成“C:\Users\user\Desktop\Mainwin - 副本\Rotation\Rotation.csproj”(默认目标): Rotation -> C:\Users\user\Desktop\Mainwin - 副本\Rotation\bin\Debug\Rotation.exe
已成功完成生成。
未处理的异常: System.InvalidOperationException: 只能在按下主鼠标按钮时调用 DragMove。
在 System.Windows.Window.DragMove()
在 Rotation.Window1.Image_MouseDown(Object sender, MouseButtonEventArgs e) 位置 c:\Users\user\Desktop\Mainwin - 副本\Rotation\Window1.xaml.cs:行号 52
在 System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
在 System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
在 System.Windows.Input.InputManager.ProcessStagingArea()
在 System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
在 System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
在 System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
在 System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
在 System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
在 System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
在 System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
在 System.Windows.Threading.Dispatcher.Run()
在 System.Windows.Application.RunDispatcher(Object ignore)
在 System.Windows.Application.RunInternal(Window window)
在 System.Windows.Application.Run(Window window)
在 System.Windows.Application.Run()
在 Rotation.App.Main() 位置 c:\Users\user\Desktop\Mainwin - 副本\Rotation\obj\Debug\App.g.cs:行号 0

2012年07月26日 02点07分 7
level 5
private void Window_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
}
这样不行吗
2012年07月26日 03点07分 8
不行的哦,点击后都没反应。。。
2012年07月26日 04点07分
@wendygeo 不会吧,我的行啊
2012年07月26日 04点07分
终于可以实现了额,因为 我使用了3DVIEWPORT 做3D 的视觉效果,3DVIEWPORT 貌似 是不支持拖拽的,但是GRID 是支持拖拽的,我把 3D VIEWPORT 套在GRID 里 对GRID 做拖拽操作,使用的是BLEND4自带了MouseDragElementBehavior的 行为,直接在资产--行为里找到,拖拽到控件上就OK了。。。
2012年07月26日 06点07分
@wendygeo 这样啊
2012年07月26日 09点07分
level 14
用API 很好解决 在能收到鼠标按下的消息的时候
SendMessage(this.handle,WM_NCLBUTTONDOWN,HTCAPTION,0);
收到鼠标释放的消息的时候
SendMessage(this.handle,WM_NCLBUTTONUP,HTCAPTION,0);
以上纯属手打,可能有记错的地方
2013年03月31日 10点03分 9
level 1
2013年06月05日 02点06分 10
level 1
WPF如何将ComboBox绑定的值转换为bool类型啊啊啊啊
2013年06月06日 08点06分 11
1