Returning complex objects from Modal #442
-
I've created a Modal which is bound to a complex object (an Address class called AddressModel). The Modal displays the custom form correctly, allows me to enter data, and when I submit the form and close the modal, I am able to see (in the debugger) the complex class is being returned as an IModalReference. I've tried to explicitly cast the returned data into a new AddressModel without success. If I call ToString() on the result, I get the correct data returned, but I want to access each individual property. My question is how do I access the properties of the complex class from the returned data? The properties are things like Street Name, Street Number, City etc. Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Hi Steve, Can you provide some code showing how you're attempting to do things currently? |
Beta Was this translation helpful? Give feedback.
-
Hi Chris, Thanks for responding so quickly. Here is some of the code I currently have. Note I will remove a lot of the XAML / Razor display code for the sake of brevity, but leave (what I think) are the important bits. First, the Address Model that I am binding the contents of the modal to:
Now the Razor control that I use to populate the Modal:
Here is the "edited" control that I want to call the modal from, and return an address as the result of the modal. Note this is a complex control, and I have removed a lot of the XAML. All the XAML and bindings are working as expected.
Thanks again for your help. I look forward to your reply. Steve. |
Beta Was this translation helpful? Give feedback.
-
I've created a work-around for this issue... I take the complex object, and turn it into a comma separated string, which I can then get from result.Data. Then, in the parent component, I reverse the process and turn the string back into an object. I'm sure there would have to be a better way than this, but it's working for the moment. |
Beta Was this translation helpful? Give feedback.
-
I was also looking for an example on how to do this. I resolved it differently. Instead of making the return value a string, I keep it as an object. And then I check if the data is of that type. So in your example that would look something like this:
|
Beta Was this translation helpful? Give feedback.
I've created a work-around for this issue...
I take the complex object, and turn it into a comma separated string, which I can then get from result.Data. Then, in the parent component, I reverse the process and turn the string back into an object.
I'm sure there would have to be a better way than this, but it's working for the moment.