ContainerUIElement3D
当鼠标悬停在我在PreviewMouserightbuttondown
事件期间移除的对象上时,我无法在 viewport3d 上使用鼠标右键执行旋转。如果我单击元素外部的其他位置,则会发生旋转并且ContainerUIElement3D
将被删除,然后添加到ViewPort3d_PreviewMouseRightButtonUp
. 这是代码:
Private _modis As ContainerUIElement3D
Public Property modis() As ContainerUIElement3D
Get
Return _modis
End Get
Set(value As ContainerUIElement3D)
_modis = value
End Set
End Property
Private Sub ViewPort3d_PreviewMouseRightButtonDown(sender As Object, e As MouseButtonEventArgs)
If My.Computer.Keyboard.CtrlKeyDown Then
ElseIf My.Computer.Keyboard.ShiftKeyDown Then
ElseIf My.Computer.Keyboard.AltKeyDown Then
Else
Dim orvps As Integer = viewPort3d.Children.Count() - 1
For ii = 0 To orvps
If viewPort3d.Children(ii).GetType.ToString() = "System.Windows.Media.Media3D.ContainerUIElement3D" Then
modis = viewPort3d.Children(ii)
viewPort3d.Children.Remove(viewPort3d.Children(ii))
Exit For
End If
Next
End If
End Sub
Private Sub ViewPort3d_PreviewMouseRightButtonUp(sender As Object, e As MouseButtonEventArgs)
If My.Computer.Keyboard.CtrlKeyDown Then
ElseIf My.Computer.Keyboard.ShiftKeyDown Then
ElseIf My.Computer.Keyboard.AltKeyDown Then
Else
If modis Is Nothing Then
Else
Try
viewPort3d.Children.Add(modis)
Catch ex As Exception
End Try
End If
End If
End Sub
主要目的是在使用鼠标右键旋转期间隐藏元素,如前所述,如果我在元素外部单击,它将旋转并隐藏元素而不会出现问题,如果我在鼠标悬停在元素上时尝试旋转我正在隐藏,它会隐藏元素并在释放鼠标按钮后再次添加它,但它不会旋转。