使用tooltip,预设显示listviewitem绑定实体指定的属性,如何根据需求动态显示某些指定的属性?
<ToolTip x:Key="InforTip">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Name,StringFormat=Name:{0}}"/>
<TextBlock Text="{Binding ImgSize,StringFormat=尺寸:{0}}"/> <TextBlock Text="{Binding Lenght,StringFormat=播放时长:{0}}"/> ……\\更多需要指定显示的属性,
</StackPanel>
</ToolTip>
<Style x:Key="InforTipStyle" TargetType="{x:Type ListViewItem}">
<Setter Property="ToolTip" Value="{Binding Source={StaticResource InforTip}}" />
</Style>
代码来源其他网站,根据提问需要作出修改
问题如下
例如实体是映射文件对象,除了文件的基本信息要显示外,根据实体的extendName属性,ToolTip 显示不同文件扩展的信息。例如图像文件,显示有关图像文件的信息,例如尺寸,其他的扩展信息不显示。音频文件显示有关音频文件的信息,播放时间,歌手,专辑等。其他的扩展信息不显示。要怎么实现?