Category Archives: WinForms

Auto Added by WPeMatico

Announcing Windows Community Toolkit v3.0 – Windows Developer Blog

I’m excited to announce the largest update to the Windows Community Toolkit yet, version 3.0.As announced a few weeks ago, we recently changed the name of the community toolkit to better align with all Windows developers, and today we are releasing our biggest update yet which introduces:
A new package for WPF and WinForms developers that includes the new Edge WebView
A new package for all XAML UWP developer to enable usage of eye gaze APIs in XAML
A new package for all .NET UWP developers to help in writing runtime API checks
A new package introducing new controls to access the Microsoft Graph
New controls and APIs in existing packages
Fluent updates to existing controls with support for light and dark theme
Updated documentation, including code examples in Visual Basic
Many improvements and bug fixes
Let’s take a look at some of these updates in more details.
A new modern WebView for .NET and WPF apps
Microsoft is bringing the latest Microsoft Edge rendering engine to .NET WinForms and WPF apps. However, working with the WebViewControl and WebView API may feel foreign to native .NET developers, so we’re building additional controls to simplify the experience and provide a more familiar environment. These controls wrap the WebViewControl to enable the control feel more like a native .NET WinForms or WPF control, and provide a subset of the members from that class.

The WinForms and WPF controls are available today in the Microsoft.Toolkit.Win32.UI.Controls package. This means that upgrading from the Trident-powered WebBrowser control to the EdgeHTML-powered WebView in your WinForms or WPF app can be as easy as dragging in a new control from the toolbox.
Visit the docs for the full documentation.
New Gaze Interaction Library to integrate eye gaze in all XAML apps
Gaze input is a powerful way to interact and use Windows and UWP apps that is especially useful as an assistive technology for users with neuro-muscular diseases (such as ALS) and other disabilities involving impaired muscle or nerve functions. The Windows 10 April 2018 Update now includes Windows eye tracking APIs. And to enable developers leveraging those APIs in their XAML apps, we are introducing the Gaze Interaction Library in the Microsoft.Toolkit.Uwp.Input.GazeInteraction package. For example, to enable eye gaze on your xaml page, add the following attached property:


The API allows you to control the customize how the eye gaze works with your UI. Make sure to read this blog to learn more and visit the docs for the full documentation.
Platform Specific Analyzer
When writing platform adaptive code, developers should ensure that code checks for presence of API before calling it. The platform specific analyzer, available through the Microsoft.Toolkit.Uwp.PlatformSpecificAnalyzer nuget package, is a Roslyn analyzer for both C# and Visual Basic that can detect when you are using APIs that might now be available on all versions of Windows 10 and help you add the appropriate code checks.

Just add the nuget package to your app and the analyzer will automatically check your code as you are developing.
Microsoft Graph controls
As part of the new Microsoft.Toolkit.Uwp.UI.Controls.Graph package, we are adding four new controls to enable developers access the Microsoft Graph in their XAML apps.
ProfileCard and AadLogin
The ProfileCard control is a simple way to display a user in multiple different formats using a combination of name, image, and email. The AadLogin control leverages the Microsoft Graph service to enable basic Azure Active Directory (AAD) sign-in process.

The PeoplePicker control allows for selection of one ore more users from an organizational AD.
The SharePointFileList control allows the user to navigate through a folder and files and displays a simple list of SharePoint files.

New controls and helpers
In addition to the new packages, the toolkit is also adding new controls and helpers to existing packages which are worth mentioning here.
CameraHelper and CameraPreview
The CameraHelper provides helper methods to easily use the available camera frame sources to preview video, capture video frames and software bitmaps. With one line of code, developers can subscribe and get real time video frames and software bitmaps as they arrive from the selected camera source.
The CameraPreview XAML control leverages the CameraHelper to easily preview the video frames in your apps.
In your xaml:

Bringing a modern WebView to your .NET WinForms and WPF Apps

One of the founding principles of Microsoft Edge is that it is evergreen, with automatic updates to Windows 10 continually refreshing both Microsoft Edge itself and web content throughout Windows 10. However, until recently, WinForms and WPF apps didn’t have access to the Microsoft Edge-powered WebView.
Earlier this week at Build 2018, Kevin Gallo previewed a new WebView for Windows 10, bringing the latest Microsoft Edge rendering engine to .NET WinForms and WPF apps for the first time in an upcoming release of Windows 10. In today’s post, we’ll provide more details on the benefits this brings to developers, and how you can preview this new capability in the Windows 10 April 2018 Update.
A WebView for the modern web
In our recent blog post on Progressive Web Apps (PWAs), we described the powerful experiences enabled by bringing a modern web platform to UWP, allowing developers to write HTML, CSS, and JS that seamlessly spans both browser as well as native app experiences.
As the growth of the web platform in general, and EdgeHTML in particular, have accelerated in recent releases, this has resulted in an increased performance and compatibility gap with the Trident-powered WebBrowser control, and many of our customers have asked for a way to incorporate the latest version of EdgeHTML into WinForms and WPF apps. We’re happy to address this feedback with a preview of the all-new EdgeHTML-powered WebView, bringing the last three years of performance, reliability, and security enhancements to WinForms and WPF apps for the first time.
Getting started
Working with the WebViewControl and WebView API may feel foreign to native .NET developers, so we’re building additional controls to simplify the experience and provide a more familiar environment. These controls wrap the WebViewControl to enable the control to feel more like a native .NET WinForms or WPF control, and provide a subset of the members from that class.
The WinForms and WPF controls are available today as a preview in the 3.0 release of the Windows Community Toolkit in the Microsoft.Toolkit.Win32.UI.Controls package. This means that upgrading from the Trident-powered WebBrowser control to the EdgeHTML-powered WebView in your WinForms or WPF app can be as easy as dragging in a new control from the toolbox.
Using WebView for WPF
Once you install the NuGet package, the WebView control appears in Windows Community Toolkit section of the Toolbox when the WPF Designer is open in Visual Studio or Blend.
Using the Designer
Drag the control from the Toolbox as you would any other control.
Programmatically adding WebView
The WPF version of the control is in the Microsoft.Toolkit.Win32.UI.Controls.WPF namespace.
Using WebView for WinForms
Using the Designer
First, we’ll need to add a WinForms control from a NuGet package to the Toolbox in Visual Studio. In a future release, Visual Studio will do this automatically.
First, open the Visual Studio Toolbox, then right-click anywhere in the toolbox, and select the Choose Items
In the .NET Framework Components tab of the Choose Toolbox Items dialog box, click the Browse button to locate the Toolkit.Win32.UI.Controls.dll in your NuGet package folder.
For help finding that folder, see Managing the global packages, cache, and temp folders.
After the DLL is added to the list of Toolbox controls, WebView is automatically
Close the Choose Toolbox Items dialog box.
The WebView control appears in the All Windows Forms section of the Toolbox when the Windows Forms Designer is open.
Programmatically adding WebView
After installing the NuGet package, you can add the WebView to your application like any other control. The WinForms version of the control is in the Microsoft.Toolkit.Win32.UI.Controls.WinForms namespace.
We’re just getting started!
The current WinForms and WPF WebView implementations are an early preview, with some limitations when compared to the UWP WebView control. For the complete list of these limitations, see Known Issues of the WebView control for Windows Forms and WPF applications on GitHub.
You can get started with WebView today using the Windows 10 April 2018 update or the latest Windows Insider Preview builds, where we’ll be adding more improvements as we continue towards a stable release. Please share your feedback or suggestions via @MSEdgeDev on Twitter, in the Windows Community Toolkit project on GitHub, or in the comments below.
Happy Coding!
– Kirupa Chinnathambi, Senior Program Manager, Microsoft Edge
– Richard Murillo, Principal Architect, Microsoft Edge

Visual Studio 2017 Update 4 makes it easy to modernize your desktop application and make it store ready

Last year with the Windows 10 Anniversary Update, we introduced the Desktop Bridge to provide desktop applications a path to modernize with the Universal Windows Platform, and to distribute via the Windows Store and the Microsoft Store for Business to all Windows 10 PCs, including devices that are running the Windows 10 S configuration.
The primary developer tool at the time was the Desktop App Converter, a tool that converts your current app installer into a Windows app package (.appx file), which can be submitted to the Windows Store or deployed via your distribution mechanism of choice. With Update 4 for Visual Studio 2017 we now have great support directly in Visual Studio for your Windows desktop application projects (WPF, Winforms, Win32, etc.). With the new tools you can now as you develop them in VS by simply hitting F5!
Let me walk you through an example, step-by-step. I am starting out with this Winforms app that showcases various chart controls. It’s been created several years ago in an older version of VS against .NET 4. Now my goal is to release it in the Windows Store and incrementally modernize it. Here is how easy it is now with Update 4 for Visual Studio 2017.

Step 1 – Add Windows App Packaging project to the solution
Before we start we need to make sure our desktop application project is loaded in Visual Studio 2017 and builds without error. Then in the next step we want to package our application as a Windows App Package (.appx file) so our Winforms app can take advantage of all the same Windows 10 app deployment features that are available to UWP apps: clean install & uninstall, seamless updates, Store distribution and many more. To do this, we will take advantage of the new tooling features introduced in Update 4 for Visual Studio 2017. We are adding a new project of type “Windows Application Packaging Project” to our solution:

Now we need to specify our min/target versions…

…and let the packaging  project know which project output to include in the package. To do so we right-click on the “Applications” node and set a reference to our Winforms project – done!

Important! Select the “DistributionPackage” project as your startup project. Now hit F5 and watch how your app gets packaged, deployed and launched as a Desktop Bridge app. You can start testing and debugging in this new execution context. If you set the Winforms project as startup project and hit F5, you can still test and debug the unpackaged version of your application
Step 2 – Configure app for Windows Store release
Our app is already running as a Desktop Bridge app now and we have successfully tested and debugged it in this configuration. Next we just need to put some finishing touches on the package so it integrates nicely with the Windows 10 Shell (tiles, badges, etc.) and to make sure it conforms to the Store submission requirements. First thing, we need to replace the default visual assets that come with the project template with our real, application-specific assets. This is very easy now in Visual Studio 2017 with the Visual Assets Manager in the package manifest editor:

To prepare for our Store submission we need to create the application in the Windows Dev Center and reserve our application name, provide screenshots for the store front, set the price, age ratings, etc. If you are not planning to distribute via the Windows Store, you can skip this step.

Last thing we need to do before we can release our app to the public is create a package bundle that is ready to deploy and Store-compliant. This bundle can contain binaries for different architectures, resources for different locales as well as the symbols for our binaries so we can later make sense of any crash reports in the Dev Center or Mobile Center. This can be done for Desktop Bridge apps directly from Visual Studio now, just like you would do for any UWP app:

As part of creating the packages we also run the certification tests and then submit the package to the Dev Center for certification and publishing. You can try the result of my submission out now and install the sample app on your machine from the Store by clicking on the badge below – source code for the app is available for your reference here.

What else does this enable for developers?
Aside from distributing and monetizing via Windows Store, your app now enjoys the modern deployment capabilities built into Windows 10. You don’t need to build an installer anymore, updates are automatic and differential. Uninstalls are guaranteed to be clean. Moreover, since your app is now in the Windows 10 App Model, you have access to UWP APIs and features, such as live tiles, Cortana integration, background tasks etc. Another important benefit specifically for Windows Forms apps is the new high DPI support in .NET 4.7, which is included in the Windows Creators Update (1703). Our sample app here is taking advantage of this new support, by following the steps outlined in this article.
And there is more
Talking about installers, did you know that your app package is also your installer on Windows 10? Users can just click to install it, as long as it’s signed with a certificate that is trusted on the target device. This enables you to distribute your modernized desktop application in the way that’s right for your scenario, without having to go through the Store – e.g. for LOB applications in an enterprise. Learn more about it here.

Getting your desktop application development project ready for Windows Store submission is easy now with Visual Studio 2017 Update 4. Once converted to a Windows App Package your app can take advantage of all the Windows 10 platform capabilities and start using new APIs and features on Windows 10. Here are some resources for more details:
Desktop Bridge docs
Desktop Bridge samples
App Modernization video on Channel 9
Are you ready to submit your desktop application to the Windows Store? Let us know about it here, and we will help you through the process!