190 likes | 354 Views
2010 1 학기. Rich Internet Application. 동서대학교 김남우. Trigger & Event Trigger. EventName Trigger 를 발생시키기 위한 Event Name SourceName Event 를 처리할 Control Name. <Grid x:Name="LayoutRoot"> …… <i:Interaction.Triggers> …… <i:EventTrigger EventName="Click"> ……
E N D
2010 1학기 Rich Internet Application 동서대학교 김남우
Trigger & EventTrigger • EventName • Trigger를 발생시키기 위한 Event Name • SourceName • Event를 처리할 ControlName <Grid x:Name="LayoutRoot"> …… <i:Interaction.Triggers> …… <i:EventTrigger EventName="Click"> …… </i:EventTrigger> …… </i:Interaction.Triggers> …… </Grid>
Added Assembly for Action <UserControl x:Class="TriggerActionExample.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" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression .Interactions” mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
Ex. of Trigger & Action <Grid x:Name="LayoutRoot"> <Button Content="Click Me" x:Name="button" Width="100" Height="100"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <ic:ChangePropertyAction PropertyName="Width" TargetName="button" Value="200"> </ic:ChangePropertyAction> </i:EventTrigger> </i:Interaction.Triggers> </Button> </Grid>
Action 대상 자신
ChangePropertyAction • TargetName : ChangePropertyAction으로 변경시키고자 하는 ControlName • PropertyName : 변경시킬 Control의 Property Name • Value : 변경될 값 • Ease : Control의 값이 변경될 때 사용할 Animation 지정 • Duration : Ease Property가 설정된 경우, Animation의 재생 시간
ChangePropertyAction <Grid x:Name="LayoutRoot" Width="400"> <Button Content="ChangedPropertyAction" Width="100" Height="100” HorizontalAlignment="Left"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <ic:ChangePropertyAction TargetName="rect1" PropertyName="Width" Value="120"/> <ic:ChangePropertyAction TargetName="rect1" PropertyName="Height" Value="120"/> </i:EventTrigger> </i:Interaction.Triggers> </Button> <Rectangle x:Name="rect1" Fill="Red" Width="100" Height="100" HorizontalAlignment="Right"/> </Grid> TargetName="rect1" [rect1]
GoToStateAction • TargetName : GoToStateAction으로 변경시키고자 하는 ControlName • StateName : 변경될 State Name
GoToStateAction <Grid x:Name="LayoutRoot" Width="400"> <Button Content="GoToStateAction" Width="100" Height="100" HorizontalAlignment="Left"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <ic:GoToStateAction TargetName="button1" StateName="MouseOver"/> </i:EventTrigger> </i:Interaction.Triggers> </Button> <Button x:Name="button1" Width="100" Height="100" Content="StateTest" HorizontalAlignment="Right"/> </Grid>
RemoveElementAction • TargetName : RemoveElementAction으로 삭제하고자 하는 ControlName
RemoveElementAction <Grid x:Name="LayoutRoot" Width="400"> <Button Content="RemoveElementAction" Width="140" Height="100" HorizontalAlignment="Left"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <ic:RemoveElementAction TargetName="rect1"/> </i:EventTrigger> </i:Interaction.Triggers> </Button> <Rectangle x:Name="rect1" Fill="Red" Width="100" Height="100" HorizontalAlignment="Right"/> </Grid>
ControlStoryboardAction • Storyboard를 Control하기 위한 Action • ControlStoryboardOption : Storyboard를 Control하는 방법 • Play, Pause, Stop 등 6가지 조작 방법 • Storyboard : Control할 StoryboardName
ControlStoryboardAction <UserControl x:Class="ControlStoryboardActionTest.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" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:im="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression .Interactions“ mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
ControlStoryboardAction <Grid x:Name="LayoutRoot" Width="400"> <Grid.Resources> <Storyboard x:Key="Storyboard1"> <DoubleAnimation Storyboard.TargetName="rect1" Storyboard.TargetProperty="Width" To="200"/> </Storyboard> </Grid.Resources> <Button Content="ControlStoryboard" Width="140" Height="100“ HorizontalAlignment="Left"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <im:ControlStoryboardAction ControlStoryboardOption="Play" Storyboard="{StaticResource Storyboard1}"/> </i:EventTrigger> </i:Interaction.Triggers> </Button> <Rectangle x:Name="rect1" Fill="Red" Width="100" Height="100" HorizontalAlignment="Right"/> </Grid>
HyperlinkAction • 특정 URL로 이동하기 위한 Action • NavigateUrl : HyperlinkAction에 의해 이동할 URL • TargetWindow : 이동하는 Page를 새 창, 현재 창 또는 특정 창을 이용할 것인지를 • 선택하기 위한 Action
HyperlinkAction <Grid x:Name="LayoutRoot" Width="400"> <Button Content="HyperlinkAction" Width="140" Height="100"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <ic:HyperlinkAction NavigateUri="http://www.daum.net" TargetWindow="_blank"/> </i:EventTrigger> </i:Interaction.Triggers> </Button> </Grid>
PlaySoundAction • Audio File을 재생하기 위해 사용하는 Action • 지원 File Format : mp3, asf, asx, wma, wmv • Source : 재생될 Audio File의 경로 • Volume : Volume 크기 (0~1)
PlaySoundAction <UserControl x:Class="ControlStoryboardActionTest.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" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:im="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression .Interactions“ mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
PlaySoundAction <Grid x:Name="LayoutRoot" Width="400"> <Button Content="PlaySoundAction" Width="140" Height="100"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <im:PlaySoundAction Source="./1.mp3" Volume="100"/> </i:EventTrigger> </i:Interaction.Triggers> </Button> </Grid>