Try assigning a name: <Button x:Name="button1" ...
.
In the associated code file: string location = button1.Text
.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
thanks for your time ... I'm having a blackout !
environment: VS2022, .net7, MAUI
How can I derive the content of the TextProperty: in this case 'Siou Blanc'?
I used n variations without success ... must be blind!
string location = Button.TextProperty.ToString();
// result: location = 'Text'
ed
<Button
Grid.Row="1"
Grid.Column="0"
Margin="8"
Command="{Binding MCommand}"
IsEnabled="{Binding IsNotBusy}"
Style="{StaticResource ButtonOutline}"
Text="Siou Blanc"/>
</VerticalStackLayout>
Try assigning a name: <Button x:Name="button1" ...
.
In the associated code file: string location = button1.Text
.
Hello,
You can do this by adding CommandParameter="{x:Reference button1}"
in the Button
like following code.
<Button x:Name="button1"
Margin="8"
Command="{Binding VARhCommand}"
CommandParameter="{x:Reference button1}"
IsEnabled="{Binding IsNotBusy}"
Style="{StaticResource ButtonOutline}"
Text="VAR-Haute"/>
Then add an attribute in your VARhAsync
of HikesViweModel.cs
. You can get the button text in the ViewModel.
[RelayCommand]
async Task VARhAsync(Button btn) {
string location = btn.Text;
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.