dotnet / dotnet/docs-maui

Just not enough detail on Command

Open
#632 2 comments 0 reactions 0 assignees View on GitHub
doc-enhancement dotnet-maui/tech dotnet-mobile/prod Pri2
Dominant language
No language data
Stars
282
Forks
265
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Hi I am struggling to make a Command and CommandParameter work in a particular example. I come here to get detailed information on how to use the CommandParameter in particular. All I get from the phone dialer example is that I can set
CommandParameter="1" and in my MVVM I can pick it up as a string.

Yet there is no more detail on the complexities of this. For instance in a CollectionView I am trying to bind to the underling object

e.g.
SelectionChangedCommand="{Binding SelectionChangedCommand}"
SelectionChangedCommandParameter="{Binding .}"

and in code

public ICommand SelectionChangedCommand => new Command( (Friend f) =>
{
Console.WriteLine($"selection made {f.property}");
});

But this doesn't work and I have no idea how to go about figuring what is going on. The documentation doesn't help. ( I have a stackoverflow question on this https://stackoverflow.com/questions/72661068/net-maui-mvvm-binding-a-selecteditemcommand-and-selecteditemparameter-from-a-co so I'm not looking for an answer here, but I am looking for insights.

If I do
SelectionChangedCommand="{Binding SelectionChangedCommand}"
SelectionChangedCommandParameter="Hello G"

public ICommand SelectionChangedCommand => new Command( (String s) =>
{
Console.WriteLine($"selection made {s}");
});

Then it works. The point is that there is nothing that explains what the {Binding .} is doing. I would assume that it is binding to the "this" of the row. But where is the explanation???

In a similar vein in order to get a tap gesture working I hacked some code to do
```



```
But where is the explanation for the syntax for this Command? What is AncestorType, what is Path etc etc.

My point is that people come to the documentation because they don't know what to do and hope to learn from the documentation how things work. This documentation is not helpful in any way. It provides a contrived example that hides the underlying concept in overlay complex code example and then stops once one example is provided. Where is the detailed documentation on the Command and CommandParameter, where is the tutorial explaining these fundamental ideas and where is the "help".

I'm sorry, but you clearly think that everyone who comes here to learn already knows what you are talking about and clearly I don't and I can't find any explanations or help and I'm getting sick of just posting questions in the hope that some expert will point out how ignorant I really am.

All I want to do is build apps, all I am ending up doing is searching for answers that don't exist. I've been on the learning path for three weeks now and it simply isn't getting any easier and I'm really hacked off.

ok rant over

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 9905cd00-f3a1-7bdd-d678-ef6c71fb53b7
* Version Independent ID: 9905cd00-f3a1-7bdd-d678-ef6c71fb53b7
* Content: [Data binding and MVVM - .NET MAUI](https://docs.microsoft.com/en-us/dotnet/maui/xaml/fundamentals/mvvm)
* Content Source: [docs/xaml/fundamentals/mvvm.md](https://github.com/dotnet/docs-maui/blob/main/docs/xaml/fundamentals/mvvm.md)
* Product: **dotnet-mobile**
* Technology: **dotnet-maui**
* GitHub Login: @davidbritch
* Microsoft Alias: **dabritch**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.