-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Improve the converters. #554
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
Conversation
Hi @llvk, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! TTYL, DNFBOT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you include some docs/explanation about what the BindableValueHolder is for and how to use it?
@llvk, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
@ScottIsAFool of course |
@ScottIsAFool done. |
/// <returns>The value to be passed to the target dependency property.</returns> | ||
public virtual object Convert(object value, Type targetType, object parameter, string language) | ||
{ | ||
var isEmpty = value == null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it not make more sense to have something like
var isEmpty = CheckValueIsEmpty(value);
where CheckValueIsEmpty is a virtual method. Given everything else in the subsequent converters is exactly the same other than this one line, would make more sense, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems clearer.
@ScottIsAFool Can I squash the branch? |
@llvk Sure. |
Make BoolToObjectConverter, EmptyCollectionToObjectConverter and EmptyStringToObjectConverter to inherit DependencyObject. Add backing DependencyProperties for all the values of converters mentioned above. Add BindableValueHolder.
I like the BindableValueHolder. I used to create custom classes for holding stuff like this. |
Really great idea! |
I extended converters the way we use them at work.
Also BindableValueHolder is very helpful thing when you use VisualState.Setters.