✅ Data Binding System.Numeric.Vector3?
I have a collection of objects containing Vector3 properties. Is it possible to data bind directly to the X/Y/Z fields in my WPF xaml data grid or do I need to add pass through properties for them all? Seems like a lot of boilerplate when you have many vectors.
10 Replies
not with properties. It's a value type, so the getter gets a copy, and trying to set a field of that retrieved copy won't affect the property itself
I’m only interested in reading the values, but it would be nice not to add 3 additional properties for each of the 7 vectors on my data object to read them all
So I’m wondering if there is some advanced way I can enable binding directly to the field rather than a property, perhaps something to do with ICustomTypeDescriptor?
TypeDescriptorProvider can only be applied to classes I control, is there any equivalent way to provide a custom type descriptor for a specific property
u mean something like this?:
MainWindow.xaml
MainWindow.xaml.cs
Yeah but because Vector3 is fields not properties those bindings don’t work
hmm
maybe create a custom class that extends
Vector3
and turn them into propertiesRight that’s the kinda thing I want to avoid
dont think u can do it any other way, not sure tho
im not an expert or anything
It’s okay, I figured it out using “TypeProvider.AddProvider” using a TypeDescriptorProvider I wrote to pretend the fields are properties for the component model.
There was a msdn magazine issue from April 2005 describing how. Required a little updating.
good
$close
If you have no further questions, please use /close to mark the forum thread as answered