带有控件模板的按钮的单击事件
Click event for Button with Control Template
我有一个带有简单控件模板的按钮:
<Page.Resources>
<ControlTemplate x:Key="LButton" TargetType="Button">
<Border BorderThickness="2" BorderBrush="White"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TextBlock FontSize="52" FontWeight="Thin"
TextAlignment="Right"
Text="Hello"
Margin="30 0 0 30"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"/>
</Border>
</ControlTemplate>
</Page.Resources>
<Button Grid.Row="1" Grid.Column="0"
Style="{StaticResource launchButton}"
Template="{StaticResource LButton}"
Margin="0 10 10 0"
x:Name="LoyalityButton" Opacity="0" Click="L_Click"/>
但是只有当我点击 TextBlock 时事件点击才会增加。我需要做什么才能使点击事件引发我触摸到按钮上的空 space 的事件?
可以设置Border的背景属性,现在是透明的,透明就是hit test不可见
我有一个带有简单控件模板的按钮:
<Page.Resources>
<ControlTemplate x:Key="LButton" TargetType="Button">
<Border BorderThickness="2" BorderBrush="White"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TextBlock FontSize="52" FontWeight="Thin"
TextAlignment="Right"
Text="Hello"
Margin="30 0 0 30"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"/>
</Border>
</ControlTemplate>
</Page.Resources>
<Button Grid.Row="1" Grid.Column="0"
Style="{StaticResource launchButton}"
Template="{StaticResource LButton}"
Margin="0 10 10 0"
x:Name="LoyalityButton" Opacity="0" Click="L_Click"/>
但是只有当我点击 TextBlock 时事件点击才会增加。我需要做什么才能使点击事件引发我触摸到按钮上的空 space 的事件?
可以设置Border的背景属性,现在是透明的,透明就是hit test不可见