wpf: Comboboxitem tooltip bug

  • .NET Core Version: NET 6, NET 5
  • Windows version: windiws 10 1803

NET 6 1

NET 5 3

<Grid>
     <ComboBox Width="100" Height="20">
         <ComboBoxItem ToolTip="1">13.42</ComboBoxItem>
         <ComboBoxItem ToolTip="2">15.82</ComboBoxItem>
     </ComboBox>
 </Grid>

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 17 (5 by maintainers)

Commits related to this issue

Most upvoted comments

@singhashish-wpf I think he got the naming confused, the issue is only happening in .NET6 (6.0.100), in .NET5 (5.0.403) the behavior is correct.

I have the exact same issue but when using Popup’s. I think this is related since ComboBox also uses a Popup. The issue seems to be coming from calling Mouse.Capture(control, CaptureMode.SubTree); on the parent control that owns the popup.

Sample control code:

<UserControl x:Class="WpfIssueControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             MouseLeftButtonDown="UserControl_MouseLeftButtonDown">
    <Grid>
        <ToggleButton x:Name="Button" 
                      Checked="Button_Checked" 
                      Unchecked="Button_Unchecked"/>

        <Popup x:Name="Popup" 
               IsOpen="{Binding IsChecked, ElementName=Button}">
            <Border Background="Gray">
                <TextBlock Text="TextBlock" 
                           ToolTip="ToolTip"
                           ToolTipService.InitialShowDelay="0"/>
            </Border>
        </Popup>
    </Grid>
</UserControl>
public partial class WpfIssueControl : UserControl
{
    public WpfIssueControl() => InitializeComponent();
    private void Button_Checked(object sender, RoutedEventArgs e) => Mouse.Capture(this, CaptureMode.SubTree);
    private void Button_Unchecked(object sender, RoutedEventArgs e) => Mouse.Capture(null);
    private void UserControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) => Button.IsChecked = false;
}

Removing the Mouse.Capture(this, CaptureMode.SubTree); call fixes the issue and makes the tooltip behave normally, obviously that is not a proper fix. As in OP the issue only happens when targeting net6.0-windows, switching to net5.0-windows also makes the tooltip behave normally.

@cheesi It is most likely that this will be delivered with the next servicing release for 6.0; This still depends on some other factors, Will keep this posted once there is a confirmation.

@toristorii This is the same issue as #6289, you should follow the status there since closed issues are less likely to receive updates.

Should this be re-opened, since the issue seems to be worse now than it was before, and it’s been a servicing release (6.0.3 came out in march)?

I made a repro of this bug: https://github.com/amirburbea/PopupRepro

Run this app under .NET 5 and .NET 6 and you’ll see that ListBoxItem has no issues with tooltip, but ComboBoxItem does.