i'm working with .NET Maui and i'm using image buttons to redirect to other views. Now I have a simple button for the profile, and I want the button to redirect to the view (XAML-File) on click. How can I do this? What I have so far is this:
Profile Template (/Views/Profile.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"
Title="Profile"
x:Class="Project.Views.Profile"
>
<VerticalStackLayout>
<Label
Text="Profile"
VerticalOptions="Center"
HorizontalOptions="Center" />
</VerticalStackLayout>
</ContentPage>
And this is my Image button:
<ImageButton Source="circle.png" Clicked="OnImageButtonClicked" WidthRequest="40" HeightRequest="40" HorizontalOptions="End"/>
code behind:
void OnImageButtonClicked(object sender, EventArgs e)
{
}
What can I do to redirect to the profile view on click?
Thank you :)
CodePudding user response:
If you want to navigate from a Content page to another content page, you can use the following code:
var nextPage = new NextPage ();
await Navigation.PushModalAsync (nextPage);
Or
var nextPage = new NextPage ();
await Navigation.PushAsync (nextPage);