-
Notifications
You must be signed in to change notification settings - Fork 668
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
TemplateBinding to ICommand property not work #4546
Comments
Should be also #4414 |
@Meloman19 can you try the fix suggested in #4414 and confirm this is the same issue? |
@StephenLPeters I tried and nothing changed. Example 2: MyControl.cs
MainWindow.xaml
MainWindow.cs
I see Button from Template and see "RUN" as content. If clicked on |
Hmm, how about using {Binding RelativeParent={RelativeParent TemplatedParent} Path=MyCommand} |
@StephenLPeters I already wrote about this :) RelativeSource works.
I know this is a low priority bug (if at all it's bug). But this behavior differs from WPF and UWP. |
Ah, sorry missed that... Hmm, this feels like it should work.... I know that there is a requirement for {TemplateBinding} that the DependencyObject you are using it on be in the visual tree. But that looks to be the case here (especially given that your template bindings to content work). @llongley suggests that a potential reason could be that the ICommand interface has a different namespace in native and managed dlls, maybe this is tripping up template binding. Would need some debugging. |
Note: Still repros on the 0.5.5 release. (And, as noted above, this works properly on system UWP XAML.) |
Just started to play with WinUI, I started with 1.2, and I just hit this issue ... and I'm really surprised to see it here since March 2021! |
Same issue as in #7003 - still present in 1.2, very annoying bug. Also very surprised to learn that this hasn't been fixed. |
Any update on this? |
Describe the bug
TemplateBinding
doesn't work for theICommand
property withButton
inside template.Steps to reproduce the bug
MainWindow
:Expected behavior
After clicking on the button, the text must become "PRESSED". But it's not.
Similar TemplateBindings to other properties work fine.
Workaround
Change
Command="{TemplateBinding MyCommand}"
To
Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=MyCommand}"
Version Info
NuGet package version:
[Microsoft.ProjectReunion 0.5.0-prerelease]
[Microsoft.ProjectReunion.Foundation 0.5.0-prerelease]
[Microsoft.ProjectReunion.WinUI 0.5.0-prerelease]
Windows app type:
The text was updated successfully, but these errors were encountered: