ViewModel Command ran when I debugged, but the View is not updated
This is my ViewModel:
When initialized,
ExecuteShowBloodPressureViewCommand
ran normally, but when I use UI to run other commands, the Execute function still ran, but the View doesn't update.7 Replies
Need more specifics. What is
ViewModelBase
? Is it your own MVVM framework? A standard one like Mvvm Toolkit or ReactiveUI?
Do you have DataTemplate
s for each VM type?
Are you using WPF? Avalonia? Something else? What does your View look like?Sorry, I hit the msg limit so I didn't provide more info.
I am using WPF, I'm not using a MVVM framework.
This is the ViewModelBase
This is the MainView.xaml
My view consists of a
ContentPresenter
, some RadioButton
, and a Title
textblock.
The binding seems to call the command normally, and the debug stop for the ExecuteShow...Command
does trigger when the corresponding Radio button is pressed.
No update on the UI tho.Looks ok to me. How are you showing
CurrentChildView
and Title
?
I'd still recommend using Mvvm Toolkit.
Wait, not ok.
public abstract class ViewModelBase
This needs to implement INotifyPropertyChanged
Mvvm Toolkit ships with very good implementations of INotifyPropertyChanged
and ICommand
. Your implementation is quite poor, although it should work once you actually implement the interface.Ah thanks, I wanted to use a framework but I'm still learning about MVVM (also more tutorial not using a fw).
Most modern tutorials are using Mvvm Toolkit, AFAIK.
Even the one I'm in the middle of writing is doing it. I cover how to DIY those types, show how they're used, and then immediately move to Mvvm Toolkit while stating to never use those old types after showing the differences. :kekw:
Too bad WPF isn't modern, I'm a bit in the dark about C# in general too, lol.
Process of less boilerplate, better life
You could check SingletonSean on YouTube for more modern WPF stuff.
Most of the improvements have been community-driven. Knowing how and when to use certain features, plus a lot of work on open source themes.