我正在使用TagVisualizer对象开发Microsoft Surface(pixelsense)应用程序 我正在寻找一种方法来捕获其他UI元素(如按钮)上的tagEnter,tagLeave事件。 例如,在以下XAML代码中,我想在TagVisualizer进入“Button1”的边界时捕获一个事件。
<Grid>
<s:TagVisualizer
Name="MaintagVisualizer" VisualizationAdded="MaintagVisualizer_VisualizationAdded"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
Height="Auto" Width="Auto"
VerticalContentAlignment="Center" >
<s:TagVisualizer.Definitions>
<s:TagVisualizationDefinition LostTagTimeout="2000" MaxCount="1" Value="0x1" Source="TagVisualizationEllipse.xaml" />
</s:TagVisualizer.Definitions>
<s:SurfaceButton Name="Button1" HorizontalAlignment="Left" VerticalAlignment="Top" Content="test" Width="120" Height="40" Margin="20" ></s:SurfaceButton>
</s:TagVisualizer>
</Grid>
答案 0 :(得分:2)
我知道这是一个很老的帖子,但我想我会在记录上放一些东西来帮助别人。
我正在做类似的事情......试图捕捉触摸事件(向下,向上等),当标签被放置在名为myMap的控件上时。
这是我开发的解决方案:首先,窗口的触摸监听器:
public SurfaceWindow1()
{
Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);
}
然后是处理程序:
void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
if (this.myMap != null)
{
string active_capture = "";
foreach (TouchPoint _touchPoint in e.GetTouchPoints(this.myMap))
{
if (_touchPoint.TouchDevice.Captured != null)
{
active_capture = _touchPoint.TouchDevice.Captured.ToString();
}
if (active_capture.Contains("TagVisualizer"))
{
//This touch was captured by the tag visualizer, therefore it must be a tag
if (_touchPoint.Action == TouchAction.Down)
{
TagTouchId = _touchPoint.TouchDevice.Id;
//now you can do whatever you like with the TouchDevice ID
}
}
}
}
}
你可以用按钮控件做同样的事情。至少这可以让你开始。