reeeeeee
Saving Draggable objects location wpf
I would be a lot less messy if I could have only type of objects (but I will need more of them because I need some additional formatting before saving value to object - for exampe: string can only include numbers)
Yeah, I know that reflection is usually better to be avoided, but this is currently the best idea I got, haha
18 replies
Saving Draggable objects location wpf
Okay, so I managed to do some "improvements", which include less hardcoding stuff.
I have two models,
CanvasPosition
and StringCanvasPosition
(this one inherits canvas position - some elements requires string, some int, so I just separated them.
Then I have bindable properties like this:
For the serialization and deserialization I used reflection.
I am saving it to File and the code looks like this:
Saving:
18 replies
Saving Draggable objects location wpf
Okay yeah, I had started with something similar and managed to make it work, which is nice. Thank you! (I should look into stuff like "sealed record", "abstract", "immutableDictionary")
Haha ye, every new way of storing data ends totally ugly... well, the above way with hardcoding every property kinda works, maybe some better idea will pop in my mind anytime soon..
It technically works, except some properties have margin set in XAML and on fresh set of
X
and Y
form file, their margin stays there and its location is actually wrong. An easy "fix" would be get rid of margins, but yea 😅18 replies