WPF - TemplateBinding无法识别成员内容

phi*_*hil 6 wpf controltemplate

好吧,所以我有一个窗口,其中包含以下资源

<Window.Resources>
    <Style TargetType="Button">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid>
                        <TextBlock Text="{TemplateBinding Content}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息,说"会员"内容"无法识别或无法访问." 我究竟做错了什么?

Nit*_*tin 11

您必须在ControlTemplate上定义TargetType

 <ControlTemplate TargetType="Button">
     <Grid>
         <TextBlock Text="{TemplateBinding Content}"/>
     </Grid>
 </ControlTemplate>
Run Code Online (Sandbox Code Playgroud)