`
ljl_xyf
  • 浏览: 618866 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

wpf RepeatButton控件

阅读更多

重复控件:

两个属性:

Delay:从用户按下鼠标左键到开始重复发送click事件的延迟时间.单位为毫秒 Delay数值必须大于等于0

Interval:当用户按下鼠标左键时,每次发出Click事件的时间间隔.单位为毫秒 Interval数值必须大于等于0

XAML:

<Page x:Class="wpfCongtrols.Page2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Page2">
        <StackPanel>
        <RepeatButton Name="rbtnAdd" Width="100" Height="50" Interval="1000" Content="增加" Click="rbtnAdd_Click"></RepeatButton>
        <Label Name="lblDisplay" Content="0"></Label>
        <RepeatButton Name="rbtnDecrease" Delay="2000" Width="100" Height="50" Content="减少" Click="rbtnDecrease_Click"></RepeatButton>
    </StackPanel>

</Page>

CS:
namespace wpfCongtrols
{
    /// <summary>
    /// Page2.xaml 的交互逻辑
    /// </summary>
    public partial class Page2 : Page
    {
        public Page2()
        {
            InitializeComponent();
        }

        private void rbtnAdd_Click(object sender, RoutedEventArgs e)
        {
            this.lblDisplay.Content = Convert.ToString(Convert.ToInt32(this.lblDisplay.Content)+1);

        }

        private void rbtnDecrease_Click(object sender, RoutedEventArgs e)
        {
            this.lblDisplay.Content = Convert.ToString(Convert.ToInt32(this.lblDisplay.Content) -1);
        }
    }
}
按住增加按钮 label值不断增加

按住减少按钮 label值不断减少

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics