小编Der*_* HD的帖子

如何在 .NET MAUI 中的按钮上使用“Clicked”方法传递参数?

我最近开始使用.Net MAUI。但是,我现在遇到了一个问题,在互联网上找不到任何帮助。我希望当我单击按钮时调用定义的单击函数。但是,我无法将参数传递给“Clicked”属性。我怎么做?

我尝试在不同在线论坛中的各种帖子的帮助下解决我的问题,但这些帖子都没有帮助,所以我正在创建自己的问题。

到目前为止我的代码:

XAML:

<Grid RowSpacing="50" Margin="50">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Border Stroke="Transparent"
                    StrokeThickness="3"
                    StrokeShape="RoundRectangle 30,30,30,30"
                    HorizontalOptions="Center"
                    BackgroundColor="White"
                    Grid.Row="0"
                    Grid.Column="0">
                <Border.GestureRecognizers>
                    <TapGestureRecognizer Tapped="onStudentSelected"/> <!-- Here i want to give a param -->
                </Border.GestureRecognizers>
                <VerticalStackLayout WidthRequest="300" HeightRequest="250">
                    <Border Stroke="#21B1FF"
                    StrokeThickness="3"
                    StrokeShape="RoundRectangle 15,15, 15, 15"
                    HorizontalOptions="Center"
                    BackgroundColor="White"
                    Margin="10">
                        <VerticalStackLayout WidthRequest="240">
                            <Label FontSize="25" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Text="Max Muster" Padding="10"/>
                        </VerticalStackLayout>
                    </Border>
                    <Border Stroke="#21B1FF"
                    StrokeThickness="3"
                    StrokeShape="RoundRectangle 15,15, 15, 15"
                    HorizontalOptions="Center"
                    BackgroundColor="White">
                        <VerticalStackLayout WidthRequest="240">
                            <Label …
Run Code Online (Sandbox Code Playgroud)

c# xaml maui

4
推荐指数
1
解决办法
5380
查看次数

标签 统计

c# ×1

maui ×1

xaml ×1