在wpf ListBox中的TextBlocks上鼠标悬停时不会触发MouseMove事件

时间:2015-06-22 14:02:38

标签: wpf listbox tooltip textblock

   <ListBox x:Name="My_ListBox"
        AlternationCount="2"
  <ListBox.ItemTemplate>
    <DataTemplate>
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="160" />
          <ColumnDefinition Width="110"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition MinHeight="28" />
        </Grid.RowDefinitions>

        <TextBlock x:Name="lblname"
         Grid.Row="0"
         Grid.Column="0"
         FontSize="14"
         Text="{Binding Label_Name}"
         MouseMove="Summary_MouseMove">
          <ToolTipService.ToolTip >
            <ToolTip>
              <TextBlock Visibility="Collapsed" x:Name="ToolTip">
                <Run Text="{Binding Label_Name}"/>
              </TextBlock>
            </ToolTip>
          </ToolTipService.ToolTip>
        </TextBlock>
        <TextBlock x:Name="lbllastname"
                   Grid.Row="0"
                   Grid.Column="1"
                   Margin="5,0"
                   FontSize="14"
                   Foreground="Black"
                   Text="{Binding Label_Value}"
                   TextWrapping="Wrap" />
      </Grid>
    </DataTemplate>
  </ListBox.ItemTemplate>
  <ListBox.ItemContainerStyle>
    <Style TargetType="ListBoxItem">
      <Setter Property="IsEnabled" Value="False" />
      <Style.Triggers>
        <Trigger Property="ItemsControl.AlternationIndex" Value="0">
          <Setter Property="Control.Background" Value="White" />
        </Trigger>
        <Trigger Property="ItemsControl.AlternationIndex" Value="1">
          <Setter Property="Control.Background" Value="White" />
        </Trigger>
      </Style.Triggers>
    </Style>
  </ListBox.ItemContainerStyle>
</ListBox>

在上面的ListBox中,我在TextBlocks中显示ListBoxItem值,MouseMove事件没有被触发,因为在TextBlock&#39; lblname&#39;上鼠标悬停时没有显示工具提示。我们可以为TextBlock显示工具提示吗?任何帮助将不胜感激,谢谢!

0 个答案:

没有答案