CiucaS
CiucaS

Reputation: 2128

WPF Ribbon ToolTip flickers

I have a very strange behavior on my Tooltips that are associated with dropdown items.

I've posted a video because it's easier to see https://i.sstatic.net/bKK4i.jpg

My XAML looks something like this

 <RibbonGroup x:Name="PageRibbonGroup" Header="{x:Static p:Resources.Page_Ribbon_Group}" LargeImageSource="{svgc:SvgImage Source='pack://application:,,,/Resources/HomeTab/Page/page_group.svg'}">
                        <RibbonComboBox>
                            <RibbonGallery x:Name="PagesListComboboxGallery" SelectedItem="{Binding XPath=.}" MaxColumnCount="1">
                                <RibbonGalleryCategory  x:Name="PagesListComboboxGalleryCategory" ItemsSource="{Binding}"/>
                                <RibbonGallery.ToolTip>                                       
                                    <ToolTip Placement="Bottom" Content="ASDF" ToolTipService.ShowDuration="5000"/>
                                </RibbonGallery.ToolTip>
                            </RibbonGallery>
                        </RibbonComboBox>
 </RibbonGroup>

This happens from what I see on every tooltip that is on an Element that is in a dropdown.

I can't find a reason on why this is happening.

I've also created a repo https://github.com/SebiCiuca/RibbonToolTipFlicker

For combobox and dropdown button you can reproduce this behavior, but for Button3 the Tooltip works fine.

Upvotes: 1

Views: 206

Answers (2)

Dan Stevens
Dan Stevens

Reputation: 6830

If you're looking for a workaround that bypasses the bug, as I am, you may be able to retarget your project to .NET 5.0. An alternative that keeps using .NET 6.0 is to publish your start-up project as self-contained deployment and configure the project with the RuntimeFrameworkVersion set to 6.0.2.

This is how you can do it from within Visual Studio 2022:

  1. In the menu click BuildPublish Selection.
  2. Click + New, select Folder in the wizard, click Next and Folder then Next again.
  3. Choose a folder for the output of the publish process and click Finish.
  4. At the bottom of the Settings panel for the publish profile, click Show all settings.
  5. In the dialog select set Deployment mode to Self-contained and click Save button. The Publish profile should look similar the image below.

Publish Selection

  1. Next, you'll need to manually edit the .csproj for. It's easiest to do this with a text editor such as VSCode or Notepad++ but even built-in Windows Notepad should do it.
  2. Once you have the '.csproj' file open, at the following XML tag beneath the <TargetFramework>net6.0-windows</TargetFramework> tag and save the project:
    <RuntimeFrameworkVersion>6.0.2</RuntimeFrameworkVersion>
  1. Return to Visual Studio, click Publish and once complete, click the Open folder link.

You can now find and run the .exe file within the publish folder and it should run your application using .NET 6.0.2 instead of the current latest 6.0.3 and the tooltip bug should no longer be present. If you still see the bug and you're not sure if you've retargeted your project correctly, you can arrange to present the value of the System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription which should return the value ".NET 6.0.2" if done correctly.

Note that if you run your project from the usual bin\Release or bin\Debug directory (as would running the project from Visual Studio) it will use whatever the current release is. Only the published application will use the previous version. You'll also need to remember to republish your project whenever you make a code change if you want to test it with the .NET 6.0.2 runtime.

Once .NET 6.0.5 is released and you want to publish your application using the new version, simply reverse step 6 above by remove the RuntimeFrameworkVersion element from the .csproj file.

Upvotes: 1

CiucaS
CiucaS

Reputation: 2128

https://github.com/dotnet/wpf/pull/6063/files

Looks like a WPF Bug introduced in version 6.0.3, that should be fixed in .NET 6.0.5

This behavior does not reproduce in .NET 5 or .NET 6.0.2.

Upvotes: 0

Related Questions