Skip to content

ControlCatalog: improve transparent appearance - #21441

Merged
maxkatz6 merged 3 commits into
AvaloniaUI:masterfrom
MrJul:fix/controlcatalog-background
May 29, 2026
Merged

maxkatz6 merged 3 commits into
AvaloniaUI:masterfrom
MrJul:fix/controlcatalog-background

Conversation

@MrJul

@MrJul MrJul commented May 27, 2026

Copy link
Copy Markdown
Member

What does the pull request do?

This PR improves the ControlCatalog sample to be a bit nicer to look at when a transparency level is active.

Example

On Windows, with TransparencyLevel = AcrylicBlur and ExtendClientAreaToDecorationsHint = true:

Before:
image

After:
image

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0065840-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

Comment thread samples/ControlCatalog/MainView.xaml.cs Outdated
Comment on lines +16 to +19
private readonly StyleInclude _transparentStyles = new(new Uri($"avares://{typeof(MainView).Assembly.GetName().Name}", UriKind.Absolute))
{
Source = new Uri("/TransparentStyles.axaml", UriKind.Relative)
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This StyleInclude can potentially be broken in AOT builds. Compiled XAML class might be trimmed, if it's not referenced statically.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typical workarounds are either x:Class or define this StyleInclude in XAML (like here)

@maxkatz6 maxkatz6 May 28, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda want to improve this C# style include handling, but I don't have any ideas, other than "root everything". And this API is too complex for source-gen C# interceptors.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. We have other places in the control catalog that aren't AOT compatible, but that's not a reason to introduce a new one.

x:Class is an appropriate solution.

(I wish we could avoid the useless code-behind here by having XamlX generate the class if it does not exist.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we could avoid the useless code-behind here by having XamlX generate the class if it does not exist.

I had a branch before, but for Avalonia.Generator. We already generate C# code there, as well as already read XAML. But, IIRC, end result was annoying in Rider intellisense, need to revisit at some point.

@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0065850-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6
maxkatz6 added this pull request to the merge queue May 29, 2026
Merged via the queue into AvaloniaUI:master with commit 9d4c952 May 29, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants