Ber*_*ryl 5 silverlight wpf styles attachedbehaviors
我使用附加行为,允许将DoubleClick事件连接到视图模型中的命令,如下面的绑定:
<ListBox Style="{StaticResource MasterListBoxStyle}"
b:SelectionBehavior.DoubleClickCommand="{Binding EditCommand}"
>
Run Code Online (Sandbox Code Playgroud)
我需要多个列表框用于演示文稿,所有这些都需要连接到EditCommand的DoubleClick.
我可以将此行为推送到我的MasterListBoxStyle中吗?怎么样?
干杯,
Berryl
<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>
Run Code Online (Sandbox Code Playgroud)
您应该能够在 WPF 中添加一个简单的 Setter,如下所示:
<Setter Property="b:SelectionBehavior.DoubleClickCommand" Value="{Binding EditCommand}" />
Run Code Online (Sandbox Code Playgroud)
假设bxmlns 在包含您的样式的 XAML 文件中定义。
但这在 Silverlight 中不起作用,因为 Setter 不支持绑定。Microsoft 正在Silverlight 5中修复此问题。
| 归档时间: |
|
| 查看次数: |
3089 次 |
| 最近记录: |