【发布时间】:2013-05-15 11:11:15
【问题描述】:
我正在尝试检测磁贴按钮上的悬停(如 onmouseover),但它必须是内置指针。我找不到内置事件,我已经尝试过了,但它给了我一个异常(在类型'Microsoft.Kinect.Toolkit.Controls.KinectUserViewer'上调用与指定绑定约束匹配的构造函数引发异常'
XAML 给出异常:
<k:KinectUserViewer k:KinectRegion.KinectRegion="{Binding ElementName=kinectRegion}" HorizontalAlignment="Center" Height="150" VerticalAlignment="Top" Width="150" Canvas.Left="820"/>
<k:KinectRegion KinectSensor="{Binding Kinect, ElementName=kinectSensorChooser1}" Height="919" Width="1920" x:Name="kinectRegion" Canvas.Top="151">
按钮由 forloop 自动创建。
CS:
public static readonly RoutedEvent HandPointerEnterEvent = EventManager.RegisterRoutedEvent(
"HandPointerEnter", RoutingStrategy.Direct, typeof(EventHandler<HandPointerEventArgs>), typeof(KinectRegion));
public static readonly RoutedEvent HandPointerLeaveEvent = EventManager.RegisterRoutedEvent(
"HandPointerLeave", RoutingStrategy.Direct, typeof(EventHandler<HandPointerEventArgs>), typeof(KinectRegion));
...
public MainWindow()
{
InitializeComponent();
KinectRegion.AddHandPointerEnterHandler(this, this.OnHandPointerEnter);
KinectRegion.AddHandPointerLeaveHandler(this, this.OnHandPointerLeave);
....
private void OnHandPointerEnter(object sender, HandPointerEventArgs handPointerEventArgs)
{
this.Close();//Trying to see if it works
}
private void OnHandPointerLeave(object sender, HandPointerEventArgs handPointerEventArgs)
{
this.Close();//Trying to see if it works
}
我试过的来自这个链接: Hand over button event in Kinect SDK 1.7
但是,如果我删除前两行(公共静态),程序可以运行,但未检测到悬停。使用这些行会引发异常。
基本上我首先尝试的是检测悬停然后关闭程序(让我知道它是否有效)。
感谢您的帮助
【问题讨论】:
-
好的,我现在正在尝试使用
ButtonBase.Click和ButtonBase.MouseEnter这可行,除了MouseEnter,MouseEnter 需要被handpointer 替换... -
我也有同样的问题。你有没有找到任何适合它的解决方案?非常感谢!
标签: c# visual-studio kinect