>> Hi, I'm James Montemagno,
Program Manager for
a Mobile Developer Tools, here at Microsoft.
Today, we're going to see how easy it is to
start building our very first iOS and
Android application directly inside a Visual Studio 2017.
So, let's head over to Visual Studio to get started.
Here, we are inside a Visual Studio 2017.
Let's go ahead and create our very first project.
Now, inside of our new project dialogue,
we have a lot of options from Android, iPhone,
and iPad, and even Apple TV and Watch Applications,
but we're going to start with Cross Platform.
In here, I'm going to select
the Mobile App based on Xamarin.Forms.
This is going to share to C Sharp
back-end for all of our business logic and
a shared native user interface powered by Xaml.
I'm going to select "Okay".
In here, we have a few different options such as
a Blank App and the platforms so we want to target.
We're then going to select a.NET Standard
library as a way of
sharing our code across each platform,
and simply, hit "Okay."
Visual Studio 2017 leaps into action,
creates three projects for me,
a.NET Standard library, my android project,
and my iOS project.
Let's zoom in and take a little bit closer look.
Notice here that I still
have a full.NET Standard library,
up top called App26,
has all my dependencies and
my shared Xamarin user interface.
I also have my android projects
and iOS projects where I can write
platform specific code because you have access to
100 percent of the APIs for each platform in C sharp,
but we're going to focus on
the shared code and the.NET Standard library.
Well, first note that I have an App.xaml,
so that's where I can add any shared resources,
such as colors that I may be using.
But hit the little arrow drop-down and will see
some code behind the App.xaml CS,
the C Sharp file associated with that Xaml page.
Note here that the application when starts,
will create a new main page.
It also has a few lifecycle events such as on start,
on sleep, and on resume.
But let's focus on that main page.
Here is the bulk of my application.
I have a Stack Layout where I can
stack different controls on top of each other,
inside of there, is a label that says
"Welcome to Xamarin Forms."
Now, I have my Android Emulator selected and we're
going to simply going to start the application.
This will fully compile my application on
my machine and then deploy it to my Android Emulator.
So, let's give it a few seconds.
Here we go. Our application has
started up inside of our Android Emulator,
and what we should see when it's finished
loading is Welcome to Xamarin.Forms.
Now, let's do something a little bit more creative.
Let's go ahead and add a button on
here and every time we click on it,
it will increase the count
and will display that to our users.
So, let's hop over to Visual Studio 2017 again.
Now, I'm going to come in and simply add a button.
Here, I'll get rich IntelliSense
showing me every property that's available,
so here is text and I'll say, "Click me."
Then, I'll add a clicked event
and we'll say a new event hammer.
This will automatically create the code and
the code behind for me that we can implement.
We'll simply finish that button element.
So, let's head to that main page
Xaml CS and the code behind,
and here is the button clicked that we just created.
I'm going to create a local variable
called Count and set it equal to zero,
and every time that button is clicked,
we'll say, Count plus plus.
Then what we do is simply say,
"That we know that the sender is a button
and we want to update the text." There it is.
We'll use some C Sharp interpellation to say,
"You clicked, count, times." There we go.
Now, all we have to do is simply
redeploy our application.
It will recompile our application and all of
our changes and redeploy it into our Android Emulator.
Here it is, Welcome to
Xamarin.Forms and a button that says "Click me."
So, let's go ahead and click it. There we go.
Every single time we continuously increase that count.
Now, we can also set our iOS project as our startup.
If you have a Mac OS machine,
you can go ahead and connect to it and use it as
a remote Mac machine to build the compile
and use a remotely iOS simulator
right on your Windows machine to launch
the same exact Android application but
an iOS with an iOS need of user interface.
To learn more and to get started,
go to docs.microsoft.com and tap on Xamarin,
then it'll give you full getting started
guide samples and everything
that you need to get started.
There you go. We built our very first iOS and
Android application inside a Visual Studio 201.
If you've any questions at all,
please feel free to reach out,
and thanks for watching.