-
Notifications
You must be signed in to change notification settings - Fork 140
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
DataTrigger: Evaluate the binding's initial value like WPF #11
Comments
I'm sorry, but I do not understand what you are asking for. Could you please elaborate on the scenario, and provide as much context as possible. Preferably, please provide a sample application that demonstrates your issue. |
Sorry, here’s a better description of the issue: I can still put together a sample if needed. |
Yes, please put together a sample and explain in detail what you're looking for. You lost me at Silverlight :) |
Haha, fair enough. I’ll put one together in the morning. |
Ahh, I see what you mean now. This is actually by design. The issue here is Property Value Precedence. You are setting the Foreground directly on the TextBlock. This explicit property will override any value set by the trigger. The reason it works in your "WPF DataTrigger" example is because you are setting the Foreground and DataTrigger in a style. So essentially, we need a way to opt-in to evaluating an explicitly set value. |
The Property Value Precedence shouldn't matter should it? ChangePropertyAction sets the property directly (unlike a Style). The issue is the Blend DataTrigger doesn't compute the initial value of Binding. You have to hook up to the AttachedObject Loaded event to set the initial value (the FixedDataTrigger class in my example). |
Honestly, that was my initial guess. I haven't actually debugged the code yet. I see the issue you have though. Definitely something that needs to be fixed. |
Looking at it more, it may be due to the fact that the Visual Tree isn't done being constructed when it evaluates the initial value so it can't set the property, hence why using the loaded event for the associated object works. |
That would make sense. I am worried about any backwards compatibility/performance issues by adding that event though. This might have to be an opt-in change. |
Yeah, I can definitely see the change having the potential to break old code so that makes sense. |
See PR #64. I think this will fix the problem. |
Amazing, thanks! |
Fixed via #64 |
I have a class that overrides DataTrigger's OnAttached/OnDetaching methods to subscribe/unsubscribe to the AssociatedObject's Loaded event so I can call EvaluateBindingChange to set the initial value of the DataTrigger similar to WPF.
The text was updated successfully, but these errors were encountered: