Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF - TemplateBinding doesn't recognize member content

Alright, so I have a window with the following resources

<Window.Resources>
    <Style TargetType="Button">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid>
                        <TextBlock Text="{TemplateBinding Content}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>

I am getting an error saying that, "The member "Content" is not recognized or is not accessible." What am I doing wrong?

like image 567
phil Avatar asked Sep 29 '13 19:09

phil


1 Answers

You will have to define TargetType on ControlTemplate

 <ControlTemplate TargetType="Button">
     <Grid>
         <TextBlock Text="{TemplateBinding Content}"/>
     </Grid>
 </ControlTemplate>
like image 170
Nitin Avatar answered Sep 22 '22 02:09

Nitin