Welcome back.
All right.
So let's look at what we're going to build in this video.
And we're going to build this using C-sharp and WPF.
So the Windows Presentation Foundation, and that will basically allow us to create this currency converter,
as you can see here, with images and beautiful little box in which we can enter values and then we
can convert from one currency to another.
Okay.
But we're starting with this one here.
As you can see, I can convert whatever amount I'm entering here into another currency.
So from US dollars to euros, if I do the same thing from Indian rupees to euros, let's do that again.
We can see that ₹1,337 are going to be €15 and 72 or $0.73, something like that.
And then I can click clear in order to clear the data and then start from scratch.
So let's see how many dollars we get for €420.
And we can see we get 476.
All right, so let's build this UI with WPF first, and then we're going to add the functionality.
So we're going to do that in the code behind and therefore let's create a new project.
And in order for this to work, we need to make one thing.
Sure.
That is, that we have an individual component.
So you go here to individual components installed and that is the NuGet manager.
So you can search for the NuGet package manager.
That's the one that we are going to require.
Also for the other parts, you might want to install SQL Server and then.
ASP.Net?
Well, if you want to use ASP.Net, but we're not going to use that here.
And yeah, that's going to be it for now.
So you can launch your Visual Studio community, for example.
In my case, it's 2019, but that should work the same way with other versions as well.
So you can then just go ahead and create a new project.
And here it's important that you select WPF app dot net framework so you can search it here.
And scroll all the way down till you find this WPF.
Net framework, because that's going to be the one that we need.
So select that template, Give it a name.
I'm going to call this one currency converter underscore static because we're going to use static numbers
and values for the currency conversion, and then let's just create the project.
And by the way, if you want to follow along a step by step guide, including the code and all of that,
you can click the link in the description.
There you will find the link to this blog article that we created.
It includes all of the code and a bunch of screenshots and a very nice step by step guide that you can
also follow along by while watching the video as well.
Once the project is ready, you will see that you have a main window.
Examle and a main window.
Examle.
CSS file opened and you have the code behind that is this CSS file?
This is this C-sharp code that you should be aware of or you should know how to read all of that because
you should have at least understood the basics of C-sharp and then the Xaml part, which is the WPF
part, so to speak.
So the Windows Presentation Foundation, which is basically an XML type of language.
So we are going to use XML in order to create our UI.
So whatever stands here is going to be translated into a UI.
And basically we want to rebuild the UI that you have seen at the beginning of the video.
Now, if you want to see what else you have in your project, you can just open up your solution Explorer.
You will see that you have this app config file which is also XML, which basically.
Can be changed per your requirements so the administrator can control which protected resources.
An application can access which version of assemblies.
An application will use the connection string, for example, for databases which we are going to see
later on.
But basically that's the app.config file.
Then you have the app dot XML file.
You can also add application resources.
So the app dot HTML file is the place to subscribe to your essential application events like application
start, then unhandled exceptions and so forth.
It is the declarative starting point of your application and the code behind is called App.xaml.cs.
So this is basically the code behind.
So your C-sharp code in which you can add the logic to your project.
But we are going to use the main window code behind to do the main window logic, because basically
we want to run our code inside of our main window and execute some good logic there.
So let's go to our main window Xaml file.
What you can see is that we have a certain height and a certain width which is created for us by default.
So if you run this application now, you will see an empty screen that will appear or an empty window
which has this height and width.
So a height of 450 pixels and the width of 800 pixels as you can see here.
And yeah, that's basically our application.
And now you could of course go ahead and drag stuff to it.
So from the toolbox you could go ahead and drag, for example, a button in there and you can run the
application once again and you will see that now there is a button, so this button doesn't do anything.
But as you can see, it's inside of your grid and it has a.
Content which says button you could change that to Hello.
And then if you look at it here at the top, you can see that this button now says hello instead of
button.
Then the Russell properties assigned to it, for example, the alignment.
So it's horizontally aligned towards the left and you have certain margins.
So for example, towards the left hand side, 388 pixels towards the top we have 116 pixels.
And if I drag this button around, you can see that those values will change.
It's vertically aligned towards the top and it has a width of 75.
So you could change that any time to, let's say, for example, 100 pixels and that would be a wider
button.
Okay.
But yeah, I'm not going to do it this way because well, I could of course drag and drop stuff in there,
but I really like to code my UI because it gives me a lot more control over the UI itself.
But as I said, you could of course open the toolbox and just see what kind of WPF controls you have.
So these are the common ones here at the top, such as pointer, border button, checkboxes, images
and so forth.
And then you have all WPF controls and you can see there are a bunch more that you can use in your WPF
project.
And you can also see what kind of properties are automatically assigned once you drag such an element
into your project.
So, for example, if I drag a label in, you can see that it has this content property.
Again, the horizontal alignment, the margin as well as the vertical alignment.
So there are a bunch of different options.
Of course there are plenty more properties that you can change.
You can just enter an empty space here and you can see that it gives you some properties that you can
directly change.
And it's not just properties, but you can also have certain commands here that you can execute some
events that are in there as well.
Context menu, opening context, menu, closing and so forth.
So a bunch of different properties.
You can just use them and play around with them to see what they do and all of that.
But of course we are going to look at the most important ones that we are going to require for this
particular application.
All right, So let's get started.