>> Hi everybody. Visual Studio 2022 is released,
and in this video,
you will see all the new great features
available there for WinForms applications.
Very quickly about me.
My name is Olia Gavrysh.
I'm Senior Program Manager on .NET team at Microsoft,
and I am working on WinForms, WPF, .NET MAUI.
If you have any questions on those areas,
feel free to reach out to me on Twitter.
I'll be happy to talk to you.
Today, we will cover what new features are
common with new Visual Studio and new .NET, .NET 6.
What improvements have been made in WinForms area.
Of course, we will do some coding together,
and I will tell you what to expect next in the future.
What is new? We enabled
64-bit support for WinForms and WPF applications.
Yes, you asked us for it for a long time and finally,
64-bit is fully supported.
We also are adding new APIs per year, class,
and we have application-wide default font,
which I will show you in my demo.
We are working on the new ways,
how you can bind to your data in your WinForms applications.
I'll show you a new data binding approach in WinForms.
Also, we added designer support
for strip controls such as MenuStrip,
ContextMenuStrip, StatusStrip, and so on.
Now you can edit those controls in the designer using your mouse.
No need to do the code behind.
It has full support in the new designer.
We keep adding new controls.
As for the new controls, in case you miss the announcement we had,
we have a new task dialog and that task dialogue was added
completely by our open source community.
Constantine Prizer was very
passionate about this area and he helped us
implement an absolutely amazing advanced message box.
You can think of it this way.
This task dialogue can have footers,
headers, buttons, check boxes, or progress bars, and so on.
I absolutely love this control, check it out.
Now you can customize messages you are sending to your clients.
Now the new control we have is WebView2.
WebView2 allows you to host
web application inside your WinForms application.
Like on my example,
I have a Twitter inside my WinForms app.
WebView control based on new Chromium device.
If you heard about web browser that was a parent
to WebView2 and it is available as a NuGet package.
Simply add Microsoft.Web.WebView2 to your project,
and you will see it in a toolbox and just drag it,
drop it on the form,
start using that abilities in your desktop application.
What improvements have been made since the last Visual Studio?
We fixed a lot of reliability bugs.
Initially our WinForms designer
that was supporting .NET core, .NET 5 and .NET 6,
now applications was in the making.
It was in the preview.
In .NET 6 and in Visual Studio 2022,
it is a much better, mature, and reliable version.
I highly recommend if you are building
your WinForms applications for core .NET 5 and .NET 6,
I really recommend you to update to Visual Studio 2022.
It is much, much better.
We improved our multiple controls editing.
If you're select like 20,
30 controls and try to move them all,
these mechanisms are much better in the latest Visual Studio.
They're more memory efficient.
Also, we have a third party control SDK improvements,
and we're constantly working with
our third-party control vendors and they're
developing their libraries that support .NET 6.
We improved designer load fast.
Designer load now happens
much faster and it happens asynchronously.
When you open your form for the first time,
before the designer used to freeze and now
you can go and edit other files.
You can start working without waiting for
the designer and designer will load up on the background.
It also happens much faster in the latest Visual Studio.
Let's continue talking about performance.
We made significant improvements in the latest .NET, .NET 6.
Here, you can see the comparison of absolutely same application
doing absolutely same tasks but in the first time on the top-level,
it targets .NET Framework and on the lower part it targets .NET 6.
Here, you can see a significant improvement.
Like 262 allocations, compare it to just 77 for .NET 6.
By simply retargeting your app from .NET Framework to .NET 6,
your application will be much faster.
Let's open Visual Studio and do some coding.
Here, I have an Air Quality application,
but even before jumping to the application,
I want to show you a very cool feature that we added in
WinForms that is called Implicit Usings.
I opened my project file and here I type "Implicit Usings enable".
I'm going to save everything.
It will make Visual Studio to figure out what libraries
I need by default and what I should not use explicitly,
such as system or a system Windows Forms.
I have my WinForms applications,
so it's obvious I'm going to need those.
Since I added that line in my project file,
now I can easily remove that from every class of
my project and just have more space for me to code.
Next thing. I don't know,
maybe you have noticed it already
that my tabs have a different color.
I have yellow tabs and purple tabs.
That is because we added the feature to
use different colored tabs for different projects.
It's very easy to turn that on.
You simply go to Tools, Options.
Here, Tabs and Windows.
I make sure that colorize document tabs by project is on,
and then you will have that colorization as well.
I personally find it super useful because when I have 15,
20 tabs open, it really helps me to navigate between them.
Another great Visual thing that we
have is different themes in Visual Studio.
Before we had just a few standard themes,
but now we did
that in the collaboration with the open source community.
You can go to Tools Theme and get more themes.
Here, you will find plenty of different themes to your taste.
Let's open this one.
Yeah, looks gorgeous.
To get it you simply click "Download" and it will appear in
your Visual Studio here and you
can easily switch between different themes.
Back to WinForms specific themes.
Let me run the application and show you what app I'm happen here.
That is an Air Quality app.
As I mentioned, it shows air quality in different cities,
in my case, in USA.
Here, I'm using user controls.
Every tile is a user control that
I developed in my WinForms designer in
Visual Studio 2022 and
my application is targeting .NET 6, the latest framework.
In .NET 6, in Visual Studio 2022,
we have a full support for user controls.
I use Designer.
I saw the user controls on the Form,
I was able to fine tune the UI to my liking,
so check it out.
I also have third party controls.
Do you see those amazingly looking round buttons
and round edit boxes?
We have a support for
different third party controls and we keep working with them,
making sure that they have a clear path to the latest .NET,
to the latest Visual Studio version.
If you're control vendor,
it doesn't matter if you're large or small,
maybe just one person, developer,
feel free to reach out to me if you have
any questions or issues in enabling your application,
enabling your controls in
the latest Visual Studio with the latest WinForms .NET 6.
We want to make sure that your control port
and bring joy to users with the latest stack that is available.
Okay, and moving on.
Here, I notice that every city is in Los Angeles.
So that obviously some error.
I'm going to debug it while my application is still running.
So I'm going to bring my application to a side.
I will go here, and yeah, look, I added this code to test
something and it just overwrites everything to Los Angeles.
Let me remove it. Just save everything,
go back to my application and look,
now, every city is the right city and I did
that while my application was still running.
This feature is called Hot Reload.
So now Hot Reload works for C# as well,
and you can change your C# code, your changes will be applied
immediately to your running application.
Here we have a Hot Reload button, let me open it.
I have Hot Reload on
File Save so I didn't even need to click anything,
I just saved my changes
and they're immediately in my running application.
Let's go back here.
I'm pretty happy with how my main form looks like,
but my detailed form, this one looks pretty plain.
I want to make it pop up.
For that, we have a new API that sets default font all over
your application and you can do it in one line.
Let me stop the application right
now and show you how you can do it.
Well, the first thing, in your main methods,
you can type applications,
set default font, and set it to the font that you want.
Those changes will work in your running application,
but they will not work in the designer.
Later, we added ability to set the default font in
the project file and that will work in the designer as well.
So by adding this line,
application default font, and I'm setting it
to some font that will really pop up.
Let me make sure, I'm going to command this line,
so nothing here, just one line in my project file.
I'm going to run the application, go to "Details" tab,
and there you go, a very curly font,
probably too curly for a business app,
but for demo purposes, I would say it work.
The last thing I wanted to show you is the new way
how you can add data binding to your application.
Let me open my Visual Studio.
In my Details tab,
I have Provider Label and I want to data bind it to some entity.
The way I'm going to do it,
I'm going to go to property window, go to very top,
open data binding,
text, and click "Add New Object Data Source".
This will bring up the new dialogue that we did not have before,
where I can select what entities I want
to add as my object data source.
I chose that and I'm going to go
inside my City Air Quality and choose "Air Provider".
Awesome. Now, the only one thing I
need to add in my details form when I'm creating it,
I'm going to pass the city air quality and I'm going to set
city air quality binding source that got
created when I just clicked that thing in properties.
I'm going to set data source to city air quality.
Now, when I run my application and go to Properties tab,
you can see I have air provider.
So that is a new way how you
can add data binding to your WinForms.
Let us know what you think.
We will have a detailed blog post that
describes how this data
binding works and what you can do with it,
you can do a lot of things.
We keep innovating in this area, so please give us feedback.
Let us know, are there other ways you
want to work with data? Do you like it?
Anything that doesn't work well for you?
We are working constantly with
our users to make sure that we're building the right experience.
So feedback is very appreciated.
With that, let me go back to my slides and
tell you what is common in the future to WinForms.
So as I mentioned, we are working on data scenarios
and really appreciate your feedback.
We will keep adding more things in this area.
We are also working on high DPI improvements.
We're going to support Per Monitor V2,
and we're going to do more fixes and
improvements in .NET 7 time-frame.
We're also working on supporting the new Windows 11 look and feel.
If you had a chance to check out Windows 11,
it has absolutely new revolutionary look
and WinForms will get that look as well.
We have a few controls that will have the old look right now,
and we're going to work to make
them support Windows 11 look and feel.
What else? Please give us feedback,
let us know what you want us to work on to improve
which areas you need some changes or innovation.
We are constantly talking to the community and we really
appreciate when you help us design the future of WinForms.
Today, you can get Visual Studio 2022 and check out
all the new features for WinForms as well as
for every other platform that it supports.
You can see what is new in the release notes or
in blog post and please give us feedback.
The best way is to do it in Visual Studio.
On your top right corner,
click on this icon and report the problem or suggest a feature.
We go through every item there.
You also feel free to reach
out to me on Twitter if you have any questions.
If something is blocking you, I'm always happy to help you.
Check out our source codes.
WinForms as well as WPF is open-sourced,
it's available on github/dotnet/winforms
or /dotnet/wpf and become a contributor.
We got a lot of contributions in our repositories and we really,
really appreciate your feedback.
So develop the WinForms future together with us.
With that, that's it.
Thank you so much for your time.
Ask questions, give us feedback. Have a great day.