1

我正在使用 WPF 列表视图。我的要求是在列表视图项上显示工具提示。以下 XAML 对我有用。

<ListView Height="174" HorizontalAlignment="Left" ItemsSource="{Binding SystemsList}" Margin="12,27,0,0" Name="listView1" VerticalAlignment="Top" Width="456">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="System Name" Width="Auto"  DisplayMemberBinding="{Binding SystemName}"/>
                <GridViewColumn Header="Network Name" Width="Auto" DisplayMemberBinding="{Binding SystemComputerName}"/>
                <GridViewColumn Header="IP Address" Width="Auto" DisplayMemberBinding="{Binding SystemIPAddress}"/>
            </GridView>
        </ListView.View>
        <ListView.ItemContainerStyle>
            <Style TargetType="{x:Type ListViewItem}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=MaxConnectionsLimitReached}" Value ="true" >
                        <Setter Property="IsEnabled" Value="False"/>
                    </DataTrigger>
                </Style.Triggers>
                <Setter Property="ToolTip" Value="{Binding Path=ToolTip1}" />

            </Style>              
        </ListView.ItemContainerStyle>
    </ListView>

但是我该如何完成以下

1) 禁用行不显示工具提示。如何展示它?

2)我想隐藏某些行的工具提示。

4

1 回答 1

1
 <Style TargetType="{x:Type ListViewItem}">
                <Style.Triggers>
                         <!-- Your DataTrigger -->

                         <!-- For hiding the ToolTip according to SomeProperty -->
                         <DataTrigger Binding="{Binding SomeProperty}" Value="SomeValue">
                              <Setter Property="ToolTip" Value="{x:Null}"/>
                         </DataTrigger>

                </Style.Triggers>
                <Setter Property="ToolTip" Value="{Binding Path=ToolTip1}" />
                <Setter Property=ToolTipService.ShowOnDisabled" Value="True"/> <!-- For Showing ToolTip even on disabled rows -->
            </Style>              
于 2013-08-02T23:07:02.290 回答