-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ToolTips no longer use ViewLocator after updating to 11.1 #16665
Comments
Some progress in narrowing this down: this issue does not reproduce with the pared-down XAML-free version from this branch of that repository, and the relevant files are small enough for me to embed here: AvaloniaRepro.csproj<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.1.2" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.2" />
</ItemGroup>
</Project> Program.csusing Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Presenters;
using Avalonia.Controls.Shapes;
using Avalonia.Controls.Templates;
using Avalonia.Data;
using Avalonia.Media;
Application app = AppBuilder.Configure<Application>()
.UsePlatformDetect()
.SetupWithClassicDesktopLifetime(args)
.Instance!;
app.DataTemplates.Add(new ViewLocator());
Window window = new()
{
Content = new Rectangle
{
Fill = Brushes.Red,
[ToolTip.TipProperty] = new { Tip = "Testing 123" },
},
};
window.Show();
app.Run(window);
public sealed class ViewLocator : IDataTemplate
{
public bool Match(object? data) => data?.GetType().GetProperty("Tip") is not null;
public Control Build(object? param) => new ContentPresenter
{
[!ContentPresenter.ContentProperty] = new Binding
{
Source = param,
Path = "Tip",
StringFormat = "{0} (from tooltip!)",
},
};
} So it has something to do with the stuff that happens in the slightly fuller version that does not also happen here. |
And here's another branch on 11.1 that also works around it, which confuses me. The change looks like: <UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:avaloniaRepro="clr-namespace:AvaloniaRepro"
x:DataType="avaloniaRepro:ToolTipViewModel"
- x:Class="AvaloniaRepro.ToolTipView">
+ x:Class="AvaloniaRepro.ToolTipView"
+ x:Name="ThisControl">
- <ContentPresenter Content="{Binding Tip, StringFormat='{}{0} (in a tooltip!)'}" />
+ <ContentPresenter Content="{ReflectionBinding DataContext.Tip, ElementName=ThisControl, StringFormat='{}{0} (in a tooltip!)'}" />
</UserControl> |
This isn't related to tooltips, but is because your The default template for |
Good catch @TomEdwardsEnscape . Yes, this is by design. |
Describe the bug
I have an Avalonia application on 11.0 that uses the ViewLocator pattern. Sometimes, I set a
ToolTip.Tip
to something that's supposed to get its template that way.When I upgraded to 11.1.2, these ToolTips stopped displaying at all.
To Reproduce
I managed to get a somewhat slim repro project and pushed it to: https://github.com/airbreather/AvaloniaRepro
When running this as-is using
dotnet run
(on my Linux desktop, which is all I have readily accessible at the moment), I get a big red rectangle with a ToolTip that reads "Testing 123 (in a tooltip!)".If I replace all the
11.0.13
to11.1.2
inAvaloniaRepro.csproj
and run it again usingdotnet run
, I get that same big red rectangle but with a blank ToolTip.Expected behavior
11.1 should behave the same as 11.0: the ToolTip should display "Testing 123 (in a tooltip!)".
Avalonia version
11.1.2
OS
Linux
Additional context
No response
The text was updated successfully, but these errors were encountered: