5

以下のバインディングのように、DoubleClickイベントをビューモデルのコマンドにワイヤリングできるようにする添付の動作を使用します。

<ListBox Style="{StaticResource MasterListBoxStyle}"
    b:SelectionBehavior.DoubleClickCommand="{Binding EditCommand}" 
     >

プレゼンテーション用に複数のリストボックスが必要です。すべてのリストボックスには、EditCommandに接続されたDoubleClickが必要です。

この動作をMasterListBoxStyleにプッシュできますか?どのように?

乾杯、
ベリール

<Style x:Key="MasterListBoxStyle" TargetType="ListBox">
    <Setter Property="ItemsSource" Value="{Binding MasterVm.AllDetailVms}" />
    <Setter Property="ItemContainerStyle" Value="{StaticResource MasterListingRowStyle}" />
    <Setter Property="IsSynchronizedWithCurrentItem" Value="True" />
    <Setter Property="AlternationCount" Value="2" />
</Style>
4

1 に答える 1

3

WPFで次のような単純なセッターを追加できるはずです。

<Setter Property="b:SelectionBehavior.DoubleClickCommand" Value="{Binding EditCommand}" />

bxmlnsがスタイルを含むXAMLファイルで定義されていると仮定します。

ただし、バインディングはSetterでサポートされていないため、これはSilverlightでは機能しません。これは、MicrosoftがSilverlight5で修正しているものです。

于 2011-05-17T16:57:03.790 に答える