A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Please try the following code, which works on my side:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MauiApp1027"
x:Class="MauiApp1027.MainPage">
<ContentPage.BindingContext>
<local:TestViewModel></local:TestViewModel>
</ContentPage.BindingContext>
<VerticalStackLayout
Padding="30,0"
Spacing="25">
<Entry x:Name="password" IsPassword="True" HorizontalOptions="Fill" />
<Button Text="OK" Margin="20,0"
Command="{Binding AcceptCommand}"
CommandParameter="{Binding x:DataType='Entry', Path= Text, Source={x:Reference password}, Mode=OneWay }" />
</VerticalStackLayout>
</ContentPage>
TestViewModel.cs
public class TestViewModel
{
public ICommand AcceptCommand { get; set; }
public TestViewModel() {
AcceptCommand = new Command <string>(acceptCommand);
}
private void acceptCommand(string obj)
{
App.Current.MainPage.DisplayAlert("Alert", "The passed data is: "+ obj, "OK");
}
}