I created a new CustomControl and rewrite the controltemplate.
Here is the controltemplate:
<Style TargetType="{x:Type local:CustomControl1}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomControl1}">
<Border >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="auto"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock ></TextBlock>
<Button Grid.Row="1"></Button>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
As you see,I used a button in the ControlTemplate,and I wants to use the click event of this button.However,it seems visual studio forbid me to using it.
PS:I wrote the ControlTemplate in Generic.xaml which visual studio auto created when I create a new CustomControl project.What's more,I am not using the English version Visual Studio,so I can only tell you the general meaning what Visual Studio said,I am very sorry about it.
How can I use the click event of the button in controltemplate?Thank you.