Problem Background
In AvaloniaUI, unlike WPF, RadialGradientBrush does not work properly when the GradientOrigin and Center values differ.
Related Issue: AvaloniaUI/Avalonia#19888
- RadialGradientBrush doesn't work when the GradientOrigin is different than the Center and the first Stop is Transparent
Conversion Procedure
1. Detect RadialGradientBrush
In WPF XAML, find the <RadialGradientBrush> element and compare the GradientOrigin and Center property values.
2. If Mismatched, Ask the User to Choose
If GradientOrigin ≠ Center, you must present the following options to the user:
RadialGradientBrush의 GradientOrigin과 Center 값이 다릅니다.
- GradientOrigin: {현재값}
- Center: {현재값}
AvaloniaUI에서는 두 값이 동일해야 정상 동작합니다.
어느 쪽 값으로 통일하시겠습니까?
1. GradientOrigin 값으로 통일 → 결과: GradientOrigin="{GO값}" Center="{GO값}"
2. Center 값으로 통일 → 결과: GradientOrigin="{C값}" Center="{C값}"
3. Conversion Example
WPF Original:
<RadialGradientBrush GradientOrigin="20%,20%" Center="28%,28%" RadiusX="75%" RadiusY="75%">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="Black" Offset="1"/>
</RadialGradientBrush>
AvaloniaUI Conversion (When GradientOrigin Is Selected):
<RadialGradientBrush GradientOrigin="20%,20%" Center="20%,20%" RadiusX="75%" RadiusY="75%">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="Black" Offset="1"/>
</RadialGradientBrush>
AvaloniaUI Conversion (When Center Is Selected):
<RadialGradientBrush GradientOrigin="28%,28%" Center="28%,28%" RadiusX="75%" RadiusY="75%">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="Black" Offset="1"/>
</RadialGradientBrush>
Precautions
- Until the user makes a selection, do not change the value arbitrarily
- If only one of GradientOrigin or Center is specified, automatically set the unspecified property to the specified value
- If GradientOrigin and Center are already the same, no modification is needed