【发布时间】:2013-06-06 08:59:41
【问题描述】:
<Window.Resources>
<ResourceDictionary>
<Style TargetType="{x:Type propgrid:PropertyGridDataAccessorItem}">
<Style.Triggers>
<Trigger Property="DataAccessorType" Value="Category">
<Setter Property="IsExpanded" Value="{Binding DisplayName, RelativeSource={x:Static RelativeSource.Self}, ConverterParameter=???, Converter={local:ExpandedCategoryConverter}}"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</Window.Resources>
问题是我不知道如何将我的 ViewModel 中的属性作为 ConverterParameter 发送。我想要像 ConverterParameter="{Binding MyValue}" 这样的东西,但这是不可能的。我尝试了这样的多重绑定:
<Trigger Property="DataAccessorType" Value="Category">
<Setter Property="IsExpanded">
<Setter.Value>
<MultiBinding Converter="{local:ExpandedCategoryConverter}">
<Binding Path="DisplayName"/>
<Binding Path="MyProperty"/>
</MultiBinding>
</Setter.Value>
</Setter>
</Trigger>
但我的属性始终为空。
有人知道如何处理这个问题吗?
提前谢谢
【问题讨论】:
-
VS 输出窗口中是否有任何绑定错误消息?至少在单个绑定中你设置了
RelativeSource,但你没有在 MultiBinding 中这样做。 -
在调试模式下的转换器类中,DisplayName 很好,但 ExpandCategory 是 - 未设置({DependencyProperty.UnsetValue})。有什么想法可以解决吗?
-
什么是 ExpandCategory?在你的问题中找不到。是否有绑定错误消息?运行应用程序时,请查看 Visual Studio 中的输出窗口。
-
这是我在 viewModel 中的属性的名称。这里的代码与 MyProperty 相同
-
绑定错误信息怎么办?