gpt4 book ai didi

wpf - 附加的行为和风格

转载 作者:行者123 更新时间:2023-12-04 20:21:39 25 4
gpt4 key购买 nike

我使用了一个附加行为,它允许将 DoubleClick 事件连接到 View 模型中的命令,如下面的绑定(bind)所示:

<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>

最佳答案

您应该能够像这样在 WPF 中添加一个简单的 Setter:

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

假设 b xmlns 在包含您的样式的 XAML 文件中定义。

但这在 Silverlight 中不起作用,因为在 Setter 中不支持绑定(bind)。这是 Microsoft 在 Silverlight 5 中修复的问题.

关于wpf - 附加的行为和风格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6034287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com