Replies: 3 comments
-
The Command property is defined on
Unclear what alternative syntax you are referring to.
Reported before as TemplateBinding not working in a visual state setter #7779 Possibly related to TemplateBinding not working with ICommand #7003 #4546 Possibly related to x:bind not working inside a visual state setter #2508 SO: https://stackoverflow.com/questions/73561708/can-i-use-templatebinding-in-a-visualstate-setter |
Beta Was this translation helpful? Give feedback.
-
On the recent Community Call you showed enthusiasm for working on open issues. I'm not sure how closely related these Also, It is used 7 times in Generic.xaml. So those are either currently broken (I haven't tested), or they work which indicates it is a C++ vs C# issue as mentioned here: #4546 (comment) I didn't spot any instances of |
Beta Was this translation helpful? Give feedback.
-
Strictly regarding its use in your code at the top, I believe the problem is one or both of these:
TemplateBinding is as optimized version of Binding that doesn't have all the same features, including no built-in converters. This may also explain why it doesn't work with ICommand #4546 (comment) (different namespaces requiring a converter). |
Beta Was this translation helpful? Give feedback.
-
In the XAML below I need to make the bindings work for
IsEqualStateTrigger
andToggleSwitch
attachedCommand
.The XAML below actually works however my guess is that I stumbled upon something that works by chance and probably should not. I need to know how to do it right because I need to make these bindings work in another app and I cannot reproduce them. I asked this question here and I have not received an answer.
This documentation shows
ElementName
working withoutAncestorType
, and this documentation showsAncestorType
working withoutElementName
. My understanding ofAncestorType
is that it is an extension, whereasElementName
is native to WinUI. I understand them to be completely different and not intended to work together. Further,AncestorType
claims it looks for a value stored in theAncestor
property:My guess is that the XAML below works because
Ancestor
is an attached property and it is inherited by child elements - but if that is the case, why isElementName
required for the binding to work? Also, In the XAML below note that the element namedlayoutRoot
is in fact aBorder
element and does not have a property named "IsExpanded" or a command namedPlaceSelectedCommand
.I can not find any documentation that discuses these two bindings working together. If any documentation exists, kindly provide a link.
Questions:
Why does
TemplateBinding
not work on theIsEqualStateTrigger
?Why does
ToggleSwitch
not have aCommand
property?Why does this crazy binding work:
Command="{Binding (ui:FrameworkElementExtensions.Ancestor).PlaceSelectedCommand, ElementName=layoutRoot, Mode=TwoWay}"
butElementName
orAncestorType
by itself does not work?Working repo is here.
Beta Was this translation helpful? Give feedback.
All reactions