level 4
单单一个图片之类的我已经可以实现拖动了。。。我制作了一个界面实现了3D旋转(双击下旋转到另一个界面去),但现在就是有一个问题,它居然实现不了窗体界面拖动了,我也用了这个代码MouseDown(object sender, MouseButtonEventArgs e)
{ if (e.LeftButton == MouseButtonState.Pressed),是不是因为弄了一个3D旋转界面,所以不能拖动了?请帮我找到解决的关键。。。
2012年07月25日 13点07分
1
level 4
我使用了右击,显示了错误。。生成项目: 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分
终于可以实现了额,因为 我使用了3DVIEWPORT 做3D 的视觉效果,3DVIEWPORT 貌似 是不支持拖拽的,但是GRID 是支持拖拽的,我把 3D VIEWPORT 套在GRID 里 对GRID 做拖拽操作,使用的是BLEND4自带了MouseDragElementBehavior的 行为,直接在资产--行为里找到,拖拽到控件上就OK了。。。
2012年07月26日 06点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
WPF如何将ComboBox绑定的值转换为bool类型啊啊啊啊
2013年06月06日 08点06分
11