.NET프로그래밍/Silverlight 3.0

RepeatButton 컨트롤

holland14 2009. 12. 2. 10:14


- 누르고 있는 동안 계속 실행할 수 있는 버튼

- 속성
    - Interval : 간격
    - Delay : 대기시간







[MainPage.xaml]


<UserControl x:Class="RiaRepeatButton.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    d:DesignHeight="300" d:DesignWidth="400">

 

    <Grid x:Name="LayoutRoot" Background="White">

        <StackPanel Background="White">

            <TextBox x:Name="txtNum" />

            <RepeatButton x:Name="btnUp" Content="" Delay="1000" Interval="500" />

            <RepeatButton x:Name="btnDown" Content="" />

        </StackPanel>

    </Grid>

</UserControl>

 







[MainPage.xaml.cs]


using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Animation;

using System.Windows.Shapes;

 

namespace RiaRepeatButton

{

    public partial class MainPage : UserControl

    {

        private int data;

        public MainPage()

        {

            InitializeComponent();

 

            txtNum.Text = data.ToString();

            this.btnUp.Click += new RoutedEventHandler(btnUp_Click);

            this.btnDown.Click += new RoutedEventHandler(btnDown_Click);

        }

 

        void btnDown_Click(object sender, RoutedEventArgs e)

        {

            txtNum.Text = (--data).ToString();

        }

 

        void btnUp_Click(object sender, RoutedEventArgs e)

        {

            txtNum.Text = (++data).ToString();

        }

    }

}