-
Notifications
You must be signed in to change notification settings - Fork 669
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
Binding to own dependency properties is not working #9678
Comments
Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you! Open similar issues:
Closed similar issues:
|
Is there any natural intelligence other than AI that can help with this problem? A hint as to the cause of the problem and a possible workaround would help. The demo project is so simple that it is surprising that binding does not work. Maybe someone has a hint on how to further analyze the problem? |
@Woopsalla Because your custom control is neither used in XAML markup nor is its IDL declaration decorated with the You can resolve this in one of two ways (and be sure to add
|
Thank you Evelyn Wu for your help. This has solved the problem. Can you recommend any documentation that goes into the subject in more depth? I spent a lot of time looking for a solution and also got suggested solutions elsewhere that actually went in the wrong direction. Perhaps the right reference can shed some light on the subject. |
@Woopsalla This MSDN article describes in-depth the requirements for different binding scenarios; if you search for |
Describe the bug
The attached demo project contains a simple GUI with a button and a derived user control MyUserControl.
MyUserControl only contains a border whose background is bound to the background of the user control:
MyUserControl also registers its own DependencyProperty AnotherBrush of type Brush:
InitClass is called in App::OnLaunched before MainWindow is created.
When the MainWindow is initialized, the brushes of the MyUserCOntrol instance are set:
When the button is pressed, the background of the MyUserControl instance is bound to its own dependency property AnotherBrush:
The background of MyUserControl should now have the same color as AnotherBrush (i.e. red). When debugging, you can see from the variable checkAnotherBrush that AnotherBrush is actually set. However, the variable checkUCBackground shows that the background is unexpectedly NULL after the binding has been applied.
However, if the background is bound to the built-in Foreground property instead, it works!
DemoApp.zip
Steps to reproduce the bug
1.Build and run the attached demo app.
2. Click the button.
3. Debug the method MainWindow::myButton_Click.
Expected behavior
Binding should also work for own dependency properties.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.5.3: 1.5.240428000
Windows version
Windows 10 (21H2): Build 19044
Additional context
Microsoft Visual Studio Community 2022 (64-bit) - Current Version 17.10.0
The text was updated successfully, but these errors were encountered: