Open VaporiZed opened 8 months ago
@KlausLoeffelmann might be the person to talk to about this.
"Funny" enough, there actually is a build-in infrastrucutre in WinForms, and for its days, it is not even bad. The thing is, it's a nightmare to discover.
And that's the reason, we need to consider a safe and predictable way to expose this. I say safe, because the internals purely based on reflection might not be ideal, let alone, when it comes to performance.
So, my proposal is introducing IValueConverter
for WinForms, which can get honored by the BindingClass
. I think, that's a reasonable thing to do.
And shouldn't be too hard.
@elachlan: BTW: It's the MVP Summit this week, so I am super busy and hard to get. But feel free to take a look what I am doing in-between, and feel also free to ping me directly, if you have ideas, concerns, questions, you might want to address quickly. Thanks for your help here!
@KlausLoeffelmann what would be the next step for this issue then? Can you point to the existing docs for the feature?
@KlausLoeffelmann do you have an issue for the proposal you cite? If not please create one and link it here. We'll then be able to close this issue as it will be resolved by the Converters proposal.
Hi @merriemcgaw and @KlausLoeffelmann! We are thinking for various options to enable our clients use the DateOnly
and TimeOnly
types inside our DateTimePicker control. The control is currently working with the DateTime
struct. Definitely support for the IValueConverter
interface inside the BindingClass
could help. Will this feature make it to .NET 9?
@icom85 this feature won't make .NET 9, but if it's something that will be beneficial I can get it on the backlog for .NET 10. I can see the benefit for sure. @KlausLoeffelmann / @JeremyKuhne what do you guys think?
.NET version
7.0
Did it work in .NET Framework?
No
Did it work in any of the earlier releases of .NET Core or .NET 5+?
No response
Issue description
If a DataBinding is created between two properties of incompatible data types, nothing happens at runtime, so it's harder to find the causing problem. I bind a property of a control to a property of a class via a BindingSource. If the data types of the properties fit, everything is fine. If they doesn't fit, the setter of the property won't be reached. But there is also no exception about the problem. Neither when not-reaching the setter nor at the app start to tell be that a DataBinding problem exists.
Steps to reproduce
Test project: WinFormsNetVB.zip
Foo
class will be reachedFoo
, change the type of the field_ClassB
and the propertyClassB
fromClassB
toClassA
ClassB
property of theFoo
class will not be reached. There is also no exception message.I expect an exception that tells me, that the data bound properties are type-incompatible, either when setting the data binding (mostly at app start) or at least when the magic of data binding will be activated after changing one of the bound properties.