notanaverageman / Bindables

Bindables converts your auto properties into Wpf dependency or attached properties.
MIT License
52 stars 9 forks source link

Add CoerceValueCallback support for WPF #24

Closed Nextra closed 2 years ago

Nextra commented 2 years ago

Fixes #23

I don't know Forms at all, so if there is equivalent functionality I can't provide it.

Explanations for a couple of cosmetic changes:

  1. Code always uses FrameworkPropertyMetadata. This is not only pretty much expected for WPF projects[^1], but it also provides a few extra constructors that only require the callbacks, which allows for tidy code generation.
  2. I changed some of the diagnostics, because it was providing misleading information by outputting the class name twice instead of the method name.
  3. The various permutations of constructors are cleanly handled by adding to a simple array and joining the result. I hope this is a reasonable approach for you.

[^1]: See remarks in the official documentation: https://docs.microsoft.com/en-us/dotnet/api/system.windows.frameworkpropertymetadata?view=windowsdesktop-6.0#remarks

notanaverageman commented 2 years ago

@Nextra Thanks for the PR! I will bump the version and create a new NuGet package.