【问题标题】:Windows Phone custom button click "area"Windows Phone 自定义按钮单击“区域”
【发布时间】:2015-04-15 16:19:50
【问题描述】:

我已经阅读了很多关于这个论点的内容,但我自己找不到关于我的具体问题的解决方案。 我在 xaml 中创建了一个自定义按钮样式(一个里面有一个字母的圆圈),用于集成到我的应用程序中的个人键盘;问题在于:单击事件仅在按下字母时才会启动,但我想让所有按钮区域都合理。 这是我的代码:

<Style x:Key="ButtonStyle" TargetType="Button">
<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="Button">
            <Grid>
                <Border CornerRadius="100" 
                BorderThickness="3" 
                BorderBrush="Black"
                Margin="1"
                Padding="0">
                    <Grid x:Name="ContentContainer">
                        <TextBlock Text="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                    </Grid>
                </Border>
            </Grid>
        </ControlTemplate>
    </Setter.Value>
</Setter>

<Button HorizontalAlignment="Left" VerticalAlignment="Top" Click="KeyboardButton_Click" Style="{StaticResource ButtonStyle}" Content="Q" MinWidth="40" MinHeight="40" />


private void KeyboardButton_Click(object sender, RoutedEventArgs e)
{
    ....
}

【问题讨论】:

    标签: events button windows-phone click


    【解决方案1】:

    我认为您没有设置背景,因此按钮区域对于触摸是不可见的。尝试在Border之外设置"Background"="Transparent"

    【讨论】:

    • 使用提供的代码对其进行了测试。在边框属性中将背景设置为透明时,它确实有效。 &lt;Border CornerRadius="100" BorderThickness="3" Background="Transparent" BorderBrush="Black" Margin="1" Padding="0"&gt;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-27
    • 2014-11-03
    • 1970-01-01
    • 2013-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多