Hi
I have recently started using VB 2019 with Xamarin so am a newbie when it comes to developing an app.
I have stated to build a simple app, but am struggling with getting pages to load with after the Main page. Am really keen to go past this stage.
I have a button declared in my XAML file Called TEST as follows:
Clicking TEST button invokes Button_Clicked in MainPage.XAML.CS as follows
The Page1.xaml is :
The Page1.xaml.cs is:
Clicking Button does nothing.
Can anyone help me resolve this and if possible explain how pages get loaded, as I would like to write correct and efficient code for my App, and can run on Android/Windows and IOS.
Thanks
I have recently started using VB 2019 with Xamarin so am a newbie when it comes to developing an app.
I have stated to build a simple app, but am struggling with getting pages to load with after the Main page. Am really keen to go past this stage.
I have a button declared in my XAML file Called TEST as follows:
C#:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="Xamarin | Open-source mobile app platform for .NET"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App1.MainPage">
<StackLayout>
<Frame BackgroundColor="#2196F3" Padding="24" CornerRadius="0">
<Label Text="Welcome to Xamarin.Forms!" HorizontalTextAlignment="Center" TextColor="White" FontSize="36"/>
</Frame>
<Button Text="TEST" Clicked="Button_Clicked"/>
<Label Text="Start developing now" FontSize="Title" Padding="30,10,30,10"/>
<Label Text="Make changes to your XAML file and save to see your UI update in the running app with XAML Hot Reload. Give it a try!" FontSize="16" Padding="30,0,30,0"/>
<Label FontSize="16" Padding="30,24,30,0">
<Label.FormattedText>
<FormattedString>
<FormattedString.Spans>
<Span Text="Learn more at "/>
<Span Text="Xamarin.Forms quickstarts - Xamarin" FontAttributes="Bold"/>
</FormattedString.Spans>
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
</ContentPage>
MainPage.XAML.CS:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace App1
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void Button_Clicked(object sender, EventArgs e)
{
[B] Page1 Pg1 = new Page1();[/B]
}
}
}
The Page1.xaml is :
C#:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="Xamarin | Open-source mobile app platform for .NET"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App1.Page1">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
The Page1.xaml.cs is:
Page1.xaml.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace App1
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Page1 : ContentPage
{
public Page1()
{
InitializeComponent();
}
}
}
Clicking Button does nothing.
Can anyone help me resolve this and if possible explain how pages get loaded, as I would like to write correct and efficient code for my App, and can run on Android/Windows and IOS.
Thanks
Last edited by a moderator: