Let's get started with you.
The controls and content controls.
First of all, here, I got my WPF demo project again.
There is no content inside of it, so it's just like you can open up your old project and just remove
everything.
Well, we created a separate list, a separate project for our Todo app, right?
So just go back to your demo application, remove everything, keep the grid and you should be good
to go.
And don't forget to remove the content from the code behind file.
Right?
We need to think about what our application should work like in the end or how it should look like to
be more specific in WPF.
Right.
So we have a view where we can click on the log in button and afterwards we will have any kind of content
that we want to display.
And as I said, what we mainly want to achieve is to switch between the content not changing like the
content itself.
So it doesn't really matter if you throw a textbox or a stack panel or whatever.
It's really more about the user controls so that we can actively switch the view and decide on what
we want to display to the user or show to the user.
So we first of all create a new element which we haven't seen so far, and it's called content control.
Well, and as the name already suggests, it controls the actual content.
Let's give it a name.
Let's say X name equals two so that we can access it from our code behind file.
Let's give it a name, let's call it main content.
Now we can write it in uppercase if we like main content, something like that.
Let's add a closing tag here and there we go.
We can have multiple content controls depending on the well complexity of your application.
You maybe want to have different content controls where each content has, let's say, different formatting.
An example here would be let's say you have a huge form to gather some data from the user and you want
to split it up.
Let's say you have two parts of that form personal information and education history, for example.
Right?
And you could split that up.
The personal information could be one content control and the education history could be another content
control.
This would be a real world usage, let's say, of the content control.
But if your application is fairly simple, you can definitely stick with a single content control.
No worries.
Now, as I said, the content control, we can use that to control the actual content.
Definitely.
We can now go to our code behind file.
If I save that here.
And since we set the name, we can also access it using main content.
Now, if we want to adjust the content, we simply call dot content and then we can finally set an object.
And you can see that if we hover above content, we can set an object.
So I want to remove that for now.
I just wanted to show you that we can for sure access the main content and set the content, but right
now we don't have anything created yet to set.
So now next up, we want to create our first user control, which we will then set as the main content.
So now right click on your project, click on Add and click on new item.
On the top right corner, you can open up the search bar, click in the search bar and search for control.
And we are searching for the WPF user control here.
There we go, User control, WPF.
Now you can see it's XML file or document and we want to name it.
Let's say we want to show a login button.
That way we would show a login view, right?
We could name it view.
That just makes sense because it's like like on, on our website or on a mobile application, you have
different screens.
You could also call it screen, I like to call it view, so let's call it login view and then simply
hit add.
Now let's explore what we have created.
Yet on the right side, you can see that we have a login view Xaml and again we have a login view Zamalek's
So we now have a C-sharp code behind file for our login view and you can see that the login view is
inherited from the user control class.
Great.
Now we could go into our main window X and now set the content of our content control to be a new login
view and we will do exactly that, including the design of the login view and the setup in the next
lesson.
So see you over there.