9 Replies
In MVVM, your ViewModel usually doesn't know anything about your View, includes the elements in it. To sync up your properties, you bind to them in your View like this
And in your ViewModel you have public properties that raise the PropertyChanged event to let the View know when to update. Since it looks like you're using ReactiveUI, it would look something like this
The command for your button will be made in a similar way. You can read about binding to commands in Avalonia with ReactiveUI here: https://docs.avaloniaui.net/docs/next/guides/data-binding/how-to-bind-to-a-command-with-reactiveui
How to Bind to a Command with ReactiveUI | Avalonia UI
This guide shows you how to bind a view model method (that performs an action) to a control that can initiate an action in response to user interaction (for example, a button). This binding is defined in XAML using the Command attribute, for example:
OHHH thanks
@vi.ness ?
Oh, you might need to change to
this.RaiseAndSetIfChanged(ref _email, value);
I haven't used ReactiveUI in a whileNo just needed to do it like this thanks for your time
it is imported by defult i do not really use it
That does create public properties but because there is no PropertyChanged event, the binding will only work from View to ViewModel. This is prob'ly fine for what you're doing now but if you want to reset the text from your ViewModel later, it won't update in the View.
Oh okay thanks for the infromation but as you said for my work this is completely fine.