-
I am running var topLevel = TopLevel.GetTopLevel(this); in my mainviewmodel in order to open a save file dialog. However, I get this error: CS1503 Argument 1: cannot convert from 'xxxxxxxxxx.ViewModels.MainViewModel' to 'Avalonia.Visual?' Does anyone know how to remedy this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
"this" has to be an Avalonia Visual, and so can't be the ViewModel. Call it in the code behind of the view, or pass a control (likely the view) to the ViewModel. |
Beta Was this translation helpful? Give feedback.
-
If you are using ReactiveUI there is a better way to do this. As I described here: #13484 (reply in thread) In any case it's considered to be bad practice to try to directly open dialogues from a view model as it does not follow the MVVM pattern properly. |
Beta Was this translation helpful? Give feedback.
-
I have a sample in preview. Unfortunately I don't find the time to finish it due to life throwing in. If you want to check it out, any comment on the samples would be welcome: Thanks |
Beta Was this translation helpful? Give feedback.
I have a sample in preview. Unfortunately I don't find the time to finish it due to life throwing in. If you want to check it out, any comment on the samples would be welcome:
https://github.com/timunie/Avalonia.Samples/tree/feature/MVVM_Dialogs/src/Avalonia.Samples/ViewInteraction
Thanks