2012-12-10 53 views
0

我需要以下指导。操纵事件应该直到视觉树直到被处理?操作事件路由

我有以下几点:

Canvas canvas = new Canvas(); 
canvas.Width = 1920; 
canvas.Height = 1200; 
canvas.IsManipulationEnabled = true; 
canvas.AddHandler(ManipulationStartingEvent, new EventHandler<ManipulationStartingEventArgs>(CanvasManipulationStarting), true); 

ScatterViewItem svi = new ScatterViewItem(); 
svi.AddHandler(ManipulationStartingEvent, new EventHandler<ManipulationStartingEventArgs>(SVIManipulationStarting), true); 
svi.Content = canvas; 

public void SVIManipulationStarting(object sender, ManipulationStartingEventArgs e) 
{ 
    //e.Handled = true; //This fires if uncommented 
} 

public void CanvasManipulationStarting(object sender, ManipulationStartingEventArgs e) 
{ 
    e.Handled = true; //This never fires regardless :(sob 
} 

如果我点击画布,在SVIManipulationStarting火上,但如果它是注释掉的CanVasManipulationStarting永远不会触发?

回答

0

没有办法,如果我的理解对不对,该Canvas不,如果你点击它提高操纵事件,该ScatterViewItem(这是Canvas的容器)引发此事件,特别是如果你处理它在Canvas操纵事件处理程序中。

  • 确定您点击画布?添加一个背景颜色来检查它。如果您Canvas没有Background颜色,直到您设置IsHitTestVisibletrue
  • 试图操纵你的Canvas而不将其添加到您的ScatterViewItem(但到其他现有的容器),它不会点击。在其他情况下检查您的Canvas行为。