概要
XAMLを独自にインタラクティブにしようと思うとInteraction.Triggersの利用は避けて通れません。
EventTriggerを使って、特定のイベントが発生したときに、要素のプロパティを変更しようとして検索をすると、不思議な事に何故かChangePropertyActionに中々辿りつけません。
プロパティを変更したいだけなのに、Storyboardを使用する方法ばかりがヒットします。
ChangePropertyActionは、Blend SDKとして配布されているのが関係しているのかも知れません。
ただ、Blend SDKを忌避する理由も見当たらないので、備忘録として残します。
サンプル
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
x:Class="Sample.MainWindow" x:Name="root"
Height="350" Width="525">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<ei:ChangePropertyAction
TargetName="root"
PropertyName="Background"
Value="Red">
</ei:ChangePropertyAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</Window>