Wpf 未在DataTemplate内部应用ControlTemplate

Wpf 未在DataTemplate内部应用ControlTemplate,wpf,datatemplate,controltemplate,Wpf,Datatemplate,Controltemplate,我有一个对象图,它显示了许多项。我希望处理这些项目上的单击事件,以便更新详细视图以显示上次单击的项目 我试图用一个ControlTemplate来实现这一点,它将应用于对象图中的DataTemplates。标记如下所示: <ContentControl Background="White"> <ContentControl.Resources> <Style TargetType="{x:Type Button}">

我有一个对象图,它显示了许多项。我希望处理这些项目上的单击事件,以便更新详细视图以显示上次单击的项目

我试图用一个ControlTemplate来实现这一点,它将应用于对象图中的DataTemplates。标记如下所示:

<ContentControl Background="White">

     <ContentControl.Resources>   

        <Style TargetType="{x:Type Button}">
             <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border Background="Transparent">
                              <ContentPresenter/>
                        </Border>
                    </ControlTemplate>
               </Setter.Value>
            </Setter>
        </Style>

        <DataTemplate DataType="{x:Type local:GraphableType}">

             <Button>
                <!-- visualization of the GraphableType -->
              </Button>
         </DataTemplate>

    </ContentControl.Resources> 
<ContentControl> 

ControlTemplate未应用于DataTemplate,它不显示任何内容。如果我在DataTemplate中设置Button.Template属性,它看起来确实可以工作。有什么想法吗?

不明白为什么要在ControlTemplate中使用DataTemplate,你想实现什么?@MBen我想自定义按钮的外观,因为我希望图形中的项目可以单击。因此,我使用自定义按钮样式包装DataTemplate的内容?列表框?树景?我认为您不需要在ControlTemplate中包含DataTemplate,您只需要将ItemTemplate设置为DataTemplate。