0

您好社区我有以下 xaml。

<UserControl x:Class="Sample.SampleController"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="410" d:DesignWidth="324">
    <UserControl.Resources>
        <Style x:Key="buttonON" TargetType="RepeatButton">

            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="RepeatButton">
                        <Grid Width="80"
                              Height="80">
                            <Image Source="/Sample;component/icons/altitude_up_yellow.png"  
                                   Stretch="Fill" RenderOptions.BitmapScalingMode="Fant"/>
                            <ContentPresenter HorizontalAlignment="Center" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </UserControl.Resources>

    <Grid Name="DriveGrid" Background="#C9000000" Width="324" Height="410">

        <RepeatButton HorizontalAlignment="Left" x:Name="button1" VerticalAlignment="Top"  IsEnabled="True" Style="{StaticResource buttonON}"  Margin="232,297,0,0" Delay="100" Interval="200" Width="80" Height="80"/>


    </Grid>
</UserControl>

以及后面的代码

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Windows.Controls.Primitives;



namespace Sample {

    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class SampleController : UserControl {

        public SampleController() {
            InitializeComponent();
            button1.Click += new RoutedEventHandler(UpBtn_Click);

        }

         void UpBtn_Click(object sender, RoutedEventArgs e) {
            Console.WriteLine("Click");
        }


    }
}

我的问题,为什么当我按住时重复按钮不连续触发?

谢谢您的帮助。

4

1 回答 1

1

总结评论。即使我无法重现问题中所述的问题,因为上面的代码对我来说很好,我在RepeatButton fires 事件中发现了非常相似的问题,只有一次!文章。没有明确的答案是什么导致了这个问题,但它可能会为尝试什么提供一些线索

于 2013-08-15T19:09:56.350 回答