Okay, so I'm learning MVVM, and I think I understand it, but one aspect of the RadDataGrid has been frustrating me.
I am trying to use CommitEdit in an MVVM like way, and I have tried two things:
<GridCommands:DataGridUserCommand Id="CommitEdit" Command="{Binding CommitChanges}"/>
and
<Budgeteer:BudgetViewCommand/> where "Budgeteer" is the namespace, and "BudgetViewCommand" is a public class derived from DataGridCommand.
Here is the relevant source:
xmlns:Budgeteer="using:Budgeteer"
xmlns:Grid="using:Telerik.UI.Xaml.Controls.Grid"
xmlns:GridCommands="using:Telerik.UI.Xaml.Controls.Grid.Commands"
<
Grid:RadDataGrid.Commands
>
<!--<GridCommands:DataGridUserCommand Id="CommitEdit" Command="{Binding CommitChanges}"/>-->
<
Budgeteer:BudgetViewCommand
/>
</
Grid:RadDataGrid.Commands
>
When I try to use GridCommands, nothing happens. The binding to CommitChanges seems to be correct, and similar bindings work in other controls. But it just won't do anything. There are no errors in my output.
When I try to use BudgetViewCommand, which is inherited from DataGridCommand, both the CanExecute and Execute work, but I haven't a clue how to get it to communicate with my ViewModel. I don't even understand how I managed to get an instance of BudgetViewCommand to begin with! The XAML created it for me?
One of the things that kinda frustrates me as I've been trying to learn MVVM with UWP is how much "under the hood" is going on. I'm trying to catch up on the 2017 way of doing things when my mind is back in the '90s with procedural / OOP way of doing things, and I'm used to explicitly telling the machine exactly what I want it to do. But now I have an instance of a class being made, and since I have no idea how it was created, I also have no way of knowing how it's going to access my ViewModel. Sigh.