RoutedEventArgs 컨트롤 - |
RoutedEventArgs.Xaml <UserControl x:Class="RiaRoutedEventArgs.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"> <Rectangle x:Name="lblRect" Fill="Blue" Margin="20"></Rectangle> <TextBlock x:Name="lblName" Text="Silverlight" FontSize="30" Foreground="White" Width="200" Height="200"></TextBlock> </Grid> </UserControl> Grid Layout 클릭시 발생) Rectgle 클릭시 발생) RoutedEventArgs.Cs 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 RiaRoutedEventArgs { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); //Grid this.LayoutRoot.MouseLeftButtonUp += new MouseButtonEventHandler //Rect this.lblRect.MouseLeftButtonUp += new MouseButtonEventHandler //TextBlock this.lblName.MouseLeftButtonUp += new MouseButtonEventHandler } void lblName_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { MessageBox.Show("TextBlock : MouseUp Event Handle"); //이벤트 버플링(부모 요소에게 이벤트 전달) 중지 : 라우팅 중지 e.Handled = true; //부모 요소로 중지 의미 } void lblRect_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { MessageBox.Show("Rectangle : MouseUp Event Handle"); } void LayoutRoot_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { MessageBox.Show("Grid Layout : MouseUp Event Handle"); //[!]이벤트 발생 시킨 개체 찾기 { //원본 개체를 사각형으로 변경 r.Fill = new SolidColorBrush(Colors.Green); } } } } |
'.Net Project > SilverLight 3.0' 카테고리의 다른 글
49장 ListBox 컨트롤 (0) | 2009.12.02 |
---|---|
48장 ComboBox 컨트롤 (0) | 2009.12.02 |
46장 InkPresenter 컨트롤 (0) | 2009.12.01 |
45장) Drag&Drop 컨트롤 (0) | 2009.12.01 |
42장) ScrollViewer 컨트롤 (0) | 2009.12.01 |