一前一后

谁能告诉我为什么下面不工作,但它确实?注意值=语法上与后者的明确使用。我不理解的差别。

<Style.Triggers>
    <DataTrigger Binding="{Binding ItemType}" Value="{x:Type log:FranchiseAiring}">
        <Setter Property="Template" Value="{StaticResource FranchiseRowStyle}" />
    </DataTrigger>
</Style.Triggers>

以上抛出异常,下面正常工作:

<Style.Triggers>
<DataTrigger Binding="{Binding ItemType}">
    <DataTrigger.Value>
        <x:Type Type="{x:Type log:FranchiseAiring}" />
    </DataTrigger.Value>
    <Setter Property="Template" Value="{StaticResource FranchiseRowStyle}" />
</DataTrigger>

例外: 必须同时指定绑定和用于DataTrigger 值。误差在标记文件对象 'System.Windows.DataTrigger' ';组件/ ResourceDictionaries / LogStyles.xaml'。第14行位置15

堆栈跟踪:    在System.Windows.Markup.XamlParseException.ThrowException(字符串消息,异常的InnerException,的Int32 LINENUMBER,的Int32 linePosition,乌里基本URI,

有帮助吗?

解决方案

有它可能通过阿努拉格链接到错误引起的,但应该知道,您使用的两个示例不是从一个XAML点精确相同。

如果您将它转换为元素属性的语法

Value="{x:Type whatever}"

你得到的是:

<DataTrigger.Value>
  <x:Type TypeName="whatever">
</DataTrigger.Value>

你在你的问题中写道实际上对应于

Value="{x:Type Type={x:Type whatever}}"

由于TypeExtension的语义的,二者应当在任何情况下我能想到的,以产生相同的值。但是对于其他目的,它们可以是不同的,并且它们可以在WPF发痒不同的错误。

由于此,有可能Value="{x:Type Type={x:Type log:FranchiseAiring}}"可能为你工作。你可能想尝试一下,了解一下。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top