質問

Hello community I have the following 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>

And the following Code Behind

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");
        }


    }
}

My question, why doesn't the repeat button fire off continously when I press and hold?

Thank you for your help.

役に立ちましたか?

解決

To sum up comments. Even though I am not able to reproduce the problem stated in the question, as the code above works fine for me, I have found very similar issue in RepeatButton fires event only once! article. There is no definite answer what's causing the issue but it may give some clues to what to try

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top