我假设这不起作用的原因是因为我的触发器正在检查空字符串或 null,但我真正拥有的是一个文本块,其 Text 属性为空(或 null)。有谁知道我可以如何轻松地修改我的触发器来实现这一点?我已经搞砸了半个小时,尝试不同的绑定/触发器/数据触发器方式,但没有运气。
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="ToolTip">
<Setter.Value>
<!--Can't be directly in tool tip, cuz tool tip is object. StringFormat will only work with string-->
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}ID: {0}
X: {1}
Y: {2}">
<Binding Path="MyClass.Id"/>
<Binding Path="MyClass.x"/>
<Binding Path="MyClass.y"/>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="ToolTip.Content" Value="{x:Static System:String.Empty}">
<Setter Property="ToolTip.Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="ToolTip.Content" Value="{x:Null}">
<Setter Property="ToolTip.Visibility" Value="Collapsed" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>