Command WPF with viewmodel
Hello, i'm looking for some help : I'm currently developing an app with wpf using the mvvm model and i'm struggling with the command of my button, i do not understand why they aren't triggered when i click on it, the break point is not hit but the viewmodel assign to my view seem to be correctly loaded. I've already tested the command which isn't the problem but it seem to come from the page cause the command trigger work on the other page but not on this one.
the second image show the click event i've setup just to test if there is a datacontext and if command work well and it seem to work cause the command is correctly triggered when i used the click event but not when i use the button with the command in the first image.
do you have any idea what can be the cause of this problem ? (i suppose it's something related to my navigation service or my host declaration with the Singleton etc. but not sure)
Or how am i supposed to debug this ?
5 Replies
I advise you to use DevExpress. As I understand it, you are violating the MVVM principles.
When using DevExpress you need to inherit
BindableBase
in your ViewModel
command example
In the xaml you need to specify DataContext
to be able to bind.
personnaly i've bind the vm with this :
In the screenshot I see that he does not see the command
i've the same thing in this page too but the command work well
ok i found my problem i guess
i forgot to add
{ get; }
at the end of my command declaration ...
in my viewmodel
public ICommand NavigateMaterialCommand { get; }