You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Access violation in auto generated x:Bind code #2572
Describe the bug
The auto generated x:Bind code triggers an access violation.
Additionally, both TemplateBinding and Binding seems to fail here... TemplateBinding says "Setter does not have a value" (despite that being entirely false) and Binding says "The parameter is incorrect"
Steps to reproduce the bug
Steps to reproduce the behavior:
I stepped through the code yesterday, and it seems the issue is this:
Connect with id 6 acquires a reference to the ColorAnimation that has its property bound to a value
Connect with id 2 updates all values, assuming all other connections where done prior and all references are valid
For some reason, Connect with id 2 is called but Connect with id 6 never got called prior to that, resulting in the framework trying to access a null pointer
Binding was working because I forgot I had changed the Setter for the Normal visual state to use a constant rather than a Binding...
If I revert that change in C# and C++ UWP projects it still works, however my XAML Islands project crashes when doing that (and that's my scenario, I don't write UWP)
Yeah, they're deferred, but I would expect Connect() to be called when the transition is undeferred. Although I wonder if the undeferred ColorAnimation is then being immediately thrown away, rather than remaining undeferred... I'm not familiar with what VSM is doing under the covers so I don't know the answer off the top of my head.
Was about to report the same bug then found this issue. This issue is affecting VisualState.StateTrigger as well. In fact, I bet it's affecting anything that is bindable.
Activity
sylveon commentedon May 29, 2020
I stepped through the code yesterday, and it seems the issue is this:

Connectwith id 6 acquires a reference to theColorAnimationthat has its property bound to a valueConnectwith id 2 updates all values, assuming all other connections where done prior and all references are validFor some reason,
Connectwith id 2 is called butConnectwith id 6 never got called prior to that, resulting in the framework trying to access a null pointersylveon commentedon May 29, 2020
Some more updates:
sylveon commentedon May 29, 2020
Even more updates:
Setterfor theNormalvisual state to use a constant rather than a Binding...Change in question being
<VisualState x:Name="Normal"> <VisualState.Setters> - <Setter Target="ForegroundBrush.Color" Value="White" /> + <Setter Target="ForegroundBrush.Color" Value="{Binding NormalForeground, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=OneWay}" /> </VisualState.Setters>(or
TemplateBindingorx:Bind)stevenbrix commentedon May 29, 2020
Adding Evelyn Wu (@evelynwu-msft) who might have an idea of what's going on.
It looks like the parser isn't calling
Connecton theColorAnimation; is theVisualTransitiondeferred?evelynwu-msft commentedon May 29, 2020
Yeah, they're deferred, but I would expect Connect() to be called when the transition is undeferred. Although I wonder if the undeferred ColorAnimation is then being immediately thrown away, rather than remaining undeferred... I'm not familiar with what VSM is doing under the covers so I don't know the answer off the top of my head.
roxk commentedon Jul 3, 2021
Was about to report the same bug then found this issue. This issue is affecting
VisualState.StateTriggeras well. In fact, I bet it's affecting anything that is bindable.A minimal repro for state trigger:
Did the same debugging sequence and could confirm the reference for the state trigger is never set in
Connectprior to updating its value.sylveon commentedon Jun 16, 2024
This 4 years old bug is, hilariously, still an issue in WinUI 3
sylveon commentedon Jun 16, 2024
However, the tags are incorrect. The bug was originally encountered in system XAML, with no WinUI at all.