大家好
我在DataTemplate中定义了一个Buton,然后给Button的Command调用一个路由命令,这样这个路由命令始终不会触发
但是我在DataTemplate外面定义一个Buton,同样的方式调用那个路由命令就可以了 
不知道这是为什么!

解决方案 »

  1.   

    <DockPanel>
      <Canvas>
        <thriple:ContentControl3D  x:Name="Ctrl3D1">
        </thriple:ContentControl3D>
        <!--这里调用thriple:ContentControl3D.RotateCommand是可以触发的-->
        <Button Command="thriple:ContentControl3D.RotateCommand" 
                CommandTarget="{Binding ElementName=Ctrl3D1}"
        </Button>  </Canvas>
            
            
      <local:NodeCoorator x:Name="NodeContor1" Graph="{Binding Path=.}">
        <ItemsControl Background="DarkCyan" ItemsSource="{Binding Path=Nodes }">
          <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
              <jas:DragCanvas/>
            </ItemsPanelTemplate>
          </ItemsControl.ItemsPanel>                    
          <ItemsControl.ItemTemplate>
            <DataTemplate>
              <Border Width="30" Height="40">            <thriple:ContentControl3D  x:Name="Ctrl3D2">
                </thriple:ContentControl3D>
                
                <!--这里调用thriple:ContentControl3D.RotateCommand就不能触发的-->
                <Button Width="28" Height="18" 
                      Command="thriple:ContentControl3D.RotateCommand" 
                      CommandTarget="{Binding ElementName=Ctrl3D2}">
                </Button>
                                        
               </Border>
             </DataTemplate>
           </ItemsControl.ItemTemplate>    </ItemsControl>
      </local:NodeConnectionAdornerDecorator>
    </DockPanel>
      

  2.   

    WPF还在我的学习计划中,现在只能帮忙顶了!
      

  3.   

    this is because 
    <ItemsControl Background="DarkCyan" ItemsSource="{Binding Path=Nodes }">
    you already bind an object,  I guess<Button Width="28" Height="18" 
      Command="thriple:ContentControl3D.RotateCommand" 
      CommandTarget="{Binding ElementName=Ctrl3D2}">
      </Button>the binding target is not included in Nodes