VisualStudio/WPF
[WPF] 다양한이벤트처리방법 Nuget XamlBehaviorsWpf
usingsystem
2023. 1. 5. 17:23
728x90
XamlBehaviorsWpf 설치
xaml에 추가 Using 추가
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
사용
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeave">
<i:InvokeCommandAction Command="{Binding TestClick}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
EventTrigger에 사용할 이벤트 입력
comman에 행위 command 입력
예제
<ComboBox x:Name="comboBox" HorizontalAlignment="Left" Margin="552,271,0,0" Grid.Row="1" VerticalAlignment="Top" Width="120">
<ComboBoxItem Content="사과"/>
<ComboBoxItem Content="포도"/>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeave">
<i:InvokeCommandAction Command="{Binding TestClick}"/>
</i:EventTrigger>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding TestClick2341abs}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ComboBox>
728x90