uno
uno copied to clipboard
[Desktop] x:Bind local does not work in Custom Control
Current behavior
Issue 1
binding to local constant works in Page
but not working in Control
<Grid
Width="{x:Bind local:MyControl.MyWidth}"
Height="{x:Bind local:MyControl.MyHeight}" />
Code behind:
public sealed partial class MyControl : Control
{
public const double MyWidth = 200;
public const double MyHeight = 200;
}
Issue 2
Discrepancy between WinAppSDK
and Desktop
: WinAppSDK
works fine with private const
while Desktop
requires public const
WinAppSDK
public sealed partial class MyControl : Control
{
private const double MyWidth = 200;
private const double MyHeight = 200;
}
Desktop
public sealed partial class MyControl : Control
{
public const double MyWidth = 200;
public const double MyHeight = 200;
}
Expected behavior
binding to local constant shall work in Control
How to reproduce it (as minimally and precisely as possible)
MINIMAL REPRO PROJECT: XBindLocalApp.zip
STEPS TO REPRODUCE:
run the app on Windows with WinAppSDK
framework selected: all works fine:
run the app on Windows with Desktop
framework selected: binding works in Page
but fails in Control
Workaround
define constant in XAML rather than in C# code behind
Works on UWP/WinUI
Yes
Environment
No response
NuGet package version(s)
"Uno.Sdk": "5.4.8"
Affected platforms
Skia (WPF)
IDE
Visual Studio 2022
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
No response