Click here to Skip to main content
15,849,996 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey,
trying to put dynamic button in list view which should go to relevant form or page on click event. right now can click on button but how will i make it to go to relevant form

What I have tried:

XAML
<?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"
             x:Class="MobilePrice.MainPage">
    <ListView ItemsSource="{Binding Names}" >
        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Grid Padding="10">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Image Source="{Binding ImageUrl}"
                               SemanticProperties.Description="{Binding ImageUrl}"
                                                          Grid.Column="0"/>
                        <Button Text="{Binding FirstName}"
                                Clicked="goto_form"
                               SemanticProperties.Description="{Binding FirstName}"
                                                          Grid.Column="0"/>
                        <Label Text="{Binding LastName}"
                               SemanticProperties.Description="{Binding LastName}"
                               Grid.Column="1"
                               Padding="10,0"/>
                    </Grid>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</ContentPage>

C#
public void goto_form(object Sender,EventArgs args)
    {
//what to do here
}
Posted
Updated 15-Jun-23 0:52am

1 solution

It's called navigation between pages. Here is a search with many solutions and information: c# maui navigation - Google Search[^]

Here is a video on the subject by the Xamaria/Maui guru: Navigating Between Pages in .NET MAUI [6 of 8] | .NET MAUI for Beginners - YouTube[^] ... check out his other videos too.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900