Button컨트롤
.NET프로그래밍/Silverlight 3.0 2009. 12. 1. 10:05 |[MainPage.xaml]
<UserControl x:Class="RiaButton.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>
<Button Content="버튼1" Click="Button_Click"></Button>
<Button Content="버튼2" x:Name="btnTwo" Click="btnTwo_Click" ClickMode="Press" />
<Button Content="버튼3" x:Name="btnThree" Click="btnThree_Click" ClickMode="Hover" />
<Button Content="버튼4" x:Name="btnFour" Click="btnFour_Click" ClickMode="Release" />
<!-- Click이벤트에 관한 코드부분을 코드비하인드페이지에서 순수xaml코드로 작성함. -->
<Button Content="버튼5" x:Name="btnFive"></Button>
</StackPanel>
</Grid>
</UserControl>
[MainPage.xaml.cs]
using System.Windows;
using System.Windows.Controls;
namespace RiaButton
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
// 생성자를 통해서 Click이벤트를 동적으로 부여
this.btnFive.Click += new RoutedEventHandler(btnFive_Click);
}
void btnFive_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("생성자를 통해서 Click이벤트 부여");
}
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("첫번째");
}
private void btnTwo_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("두번째");
}
private void btnThree_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("세번째");
}
private void btnFour_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("네번째");
}
}
}
'.NET프로그래밍 > Silverlight 3.0' 카테고리의 다른 글
TextBox 컨트롤 (0) | 2009.12.01 |
---|---|
Label 컨트롤 (0) | 2009.12.01 |
CanvasClip - Canvas영역에서 일부분만 잘라내어 보여주기 (0) | 2009.12.01 |
CanvasSize - 실버라이트 적용할 영역 사이즈 조정하기 (0) | 2009.12.01 |
Canvas.ZIndex (사각형(도형) 포개는 순서 바꾸기) (0) | 2009.12.01 |