-
Hello, bit of a beginners question but I did not figure it out using the ReactiveUI docs. With the MVVM template I started a new project in Visual Studio 2022.
This is my ViewModel:
But with I did the binding manually here: But this does not seem correct ^^ |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Why do you have "new event" in your view model? |
Beta Was this translation helpful? Give feedback.
-
Hi @ckorn I see a couple of things here: public class MainWindowViewModel : ViewModelBase
{
public string Log
{
get => log;
set => this.RaiseAndSetIfChanged(ref _searchTerm, value); // this will update the field and also notify your UI. No need to do it by hand.
}
// The beacking field should not be public
private string log = ""; // The beacking field should not be public
// You really don't need this.
// public new event PropertyChangedEventHandler? PropertyChanged;
} Read more about this here: https://www.reactiveui.net/docs/getting-started/compelling-example Happy coding |
Beta Was this translation helpful? Give feedback.
-
Oh, wow. I already read about RaiseAndSetIfChanged but it was not visible in my scope. So I thought it was some old technique because the example here looks way more complicated: I did not expect it to be just an extension method. This is why I hate extension methods 😑 |
Beta Was this translation helpful? Give feedback.
Hi @ckorn
I see a couple of things here:
Read more about this here: https://www.reactiveui.net/docs/getting-started/compelling-example
Happy coding
Tim