Expression Blend 4を入れてみた
Expression Blend 4ってMVVMをサポートしていると謳っているんですね。
New ProjectでSilverlight Databound Applicationというテンプレートを選ぶと、ViewとViewModelを使った簡単なサンプルが含まれるプロジェクトが生成されました。そして、ViewからViewModelを呼び出すコードはトリガー(ビヘイビア)を使っていました。
<Button Content="Update Value" Height="41" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,125,0,0"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <ic:CallMethodAction MethodName="ViewModelMethod" TargetObject="{Binding}"/> </i:EventTrigger> </i:Interaction.Triggers> </Button>
ドキュメントにも、MVVMで使えるビヘイビアという位置づけで説明されていました。
New behaviors for use with applications that use the Model-View-ViewModel pattern include the following: CallMethodAction, InvokeCommandAction, and DataStateBehavior. You can use these behaviors to invoke behavior on your ViewModels, or to respond to changes to their properties.
http://msdn.microsoft.com/en-us/library/cc294722%28Expression.40%29.aspx
先日見つけたPrism4.0 Drop3のサンプルもフォルダ構成を見るにExpression Blendを使って作られたんだと思います。ビヘイビアは、Silverlight標準の機能になっていてほしいなぁ。