
-
08 Oct, 2022
.NET Knowledge
Status Bar Styling
With this release of the .NET MAUI Community Toolkit, you now get StatusBarBehavior, which allows you to easily customize the color and style of the status bar on iOS and Android either through code or in XAML. It is implemented as a Behavior meaning you can change it per page or even dynamically in response to user actions or application status.
There are two properties that you can use to control the look of the status bar:
- StatusBarColor: allows you to specify the color of the status bar background.
- StatusBarStyle: allows you to control if the content (text and icons) on the status bar is light, dark, or the system default.
Note: These two properties are Bindable, so you can also bind these values from your ViewModels.
Here is an example of how to use these properties in XAML:
<toolkit:StatusBarBehavior StatusBarColor="HotPink" StatusBarStyle="LightContent"/>
Or, if you prefer writing your UI’s in C# code:
var status behavior = new StatusBarBehavior()
{
StatusBarColor = Colors.HotPink,
StatusBarStyle = StatusBarStyle.LightContent
}
this.Behaviors.Add(statusBehavior);
And now, with just a couple of lines of code, you have a beautifully styled status bar that can match the theme of your application.
You can read more about the other features of StatusBarBehavior and see more examples in our docs. Gerald Versluis has also put together a great video demonstrating how to get started.
Gravatar Image Source
A Gravatar (globally recognized avatar) is an image that can be used as your avatar — that is, an image that represents you or your users, such as in a forum post or a blog comment. You can learn more about Gravatar or register your own at the Gravatar website.
With this release of the .NET MAUI Community Toolkit, you can easily display Gravatar images next to people’s names or email addresses via the GravatarImageSource.
You can use GravatarImageSource anywhere you would normally use an ImageSource, for example:
<toolkit:GravatarImageSource Email="youremail@here.com" />
The Email property specifies the Gravatar account email address. However, there are also properties to determine the default image if the Email is not found on Gravatar as well as inbuilt caching capabilities. All these properties are backed by BindableProperty which means they can be targets for data binding and styled.
Read more about the other features of GravatarImageSource and see more examples in our docs.
Animations
This release of the .NET MAUI Community Toolkit enhances the existing AnimationBehavior capabilities by introducing the FadeAnimation to provide the ability to animate the opacity of a VisualElement from its original opacity to a specified new opacity and then back to the original.
This allows you to specify animations in XAML that respond to user interactions.
<Button Text="Click this Button">
<toolkit:AnimationBehavior EventName="Clicked">
<toolkit:FadeAnimation Opacity="0.2"/>
In future releases, we will be building on the animations to provide Flip, Rotate, Scale, and Shake animations. Contributions are always welcome, so if you are keen to help, see the contributing section below to find out how.
Source Link
Source Link is a technology that provides first-class source debugging experiences for binaries. With this release, we have configured our builds to use Source Link, which means if you have Source Link enabled in Visual Studio you can expect an even better-debugging experience whilst using the .NET MAUI Community Toolkit. This blog post can find more information about Source Link and how to enable it
Other Fixes
This release also includes numerous bug fixes and code quality improvements. Check out the release notes for a complete list of changes.
Contributing
The .NET MAUI Community Toolkit is a community effort powered by your contributions. If you would like to contribute, feel free to open issues or let us know about your experience! You can also check out our previous post about Contributing to .NET MAUI Community Toolkit.
Summary
We hope you enjoy the latest release of the .NET MAUI Community toolkit. You can find all source code and sample apps in our GitHub repo and browse the official documentation.
A massive thank you to all the contributors and don’t forget you can join us live on the 1st Thursday of each month @ 1200 PT, where we live-stream our stand-ups on the .NET Foundation YouTube Channel.
Migrating from ASP.NET to ASP.NET Core (Part 4)
ASP.NET Core is a unified and modern web framework. NET. Migrating existing ASP.NET apps to ASP.NET Core has many advantages, including better performance, cross-platform support (Windows, macOS, Linux), and access to all the latest improvements to the modern .NET web platform. But migrating from ASP.NET to ASP.NET Core can be very challenging and time-consuming due to the many differences between the two frameworks. That’s why we’ve been working to provide libraries and tooling for performing incremental migrations from ASP.NET to ASP.NET Core so that you can slowly migrate existing ASP.NET apps a piece at a time while still enabling ongoing app development. We’ve been working on tooling in Visual Studio to simplify the migration experience, and a new update to the incremental ASP.NET migration tooling is now available.
Download and install the extension
In this series we’ve previously posted the following posts related to project migrations:
- Incremental ASP.NET to ASP.NET Core Migration
- Incremental ASP.NET Migration Tooling Preview 2
- Migrating from ASP.NET to ASP.NET Core in Visual Studio
In this blog post, we’ll cover the significant updates to the Project Migrations Extension as well as updates to the System. Web Adapters.
Updates to Visual Studio tooling
We’ve made the following improvements to the incremental migration tooling:
- Incrementally migrate class library projects, including both C# and VB.
- Incrementally migrate ASP.NET Framework projects with references to class library project(s).
- Incrementally migrate VB ASP.NET Framework projects, excluding VB view files.
- Various UX improvements across the extension.
We’ll expand on each of these topics under the headings below.
Support for Class Library projects
The extension now has support for incrementally migrating .NET Framework class library projects to .NET 6 or 7. This includes both C# and VB class library projects.
Migrating class library projects is typically much simpler than migrating ASP.NET projects. However, class library projects may contain lots of code that needs to be migrated. This may make it difficult to migrate the entire project at once. And while the class library is being migrated, projects that reference the class library still need to function.
Incrementally migrating class library projects enables you to migrate to the latest .NET versions in manageable steps. In addition, when you migrate items from an ASP.NET project that depends on code in a class library, the extension can determine those dependencies and migrate them as needed. With this approach, the original .NET Framework project is not modified and can still be referenced by other projects.
If you’re planning to incrementally migrate an ASP.NET Framework project that depends on one or more class library projects, it’s recommended to use the Migrate Project feature on all the class library projects first. When you migrate a .NET Framework class library project, a new class library project will be created targeting .NET 6/7. You’ll be prompted to select the version of .NET to target. The class library projects do not need to be fully migrated before the web project. At that point, none of the content from the original project will be migrated. Items will be migrated as you migrate items in the ASP.NET Framework project. From here, you can start to incrementally migrate code directly from the original class library to the new .NET Core class library, or you can migrate code from the web project which will automatically migrate dependent code from the original class library to the new class library project. In the section below we’ll describe how to migrate ASP.NET Framework projects that depend on class library projects.
Incrementally migrate ASP.NET Framework projects with references to class library project(s)
Now that the extension can migrate class library projects, that has been integrated into the process of migrating content from ASP.NET Framework projects to ASP.NET Core projects. For example, if you migrate an MVC controller from your ASP.NET Framework project and the controller being migrated depends on code in a dependent class library project, the dependent code will be migrated as well as long as the code lives in a project with a corresponding migration project. Note that this means you must perform Migrate Project on each .NET Framework class library project that the ASP.NET Framework project depends on. Once this association has been made, the extension can automatically migrate items across projects as needed. This works best for C# ASP.NET Framework projects. Support for the VB Framework project has some special considerations which we’ll expand on in the next section.
If you’ve already migrated some items from the ASP.NET Framework project before migrating the class library project(s), you can migrate the class library project(s) and then re-run the migrations for the items which have already been migrated. In the next run, the dependencies in the class library project(s) will be detected and migrated.
Incrementally migrate VB ASP.NET Framework projects
In previous releases, we didn’t have any support for VB ASP.NET Framework projects. In this release, we added support for incrementally migrating VB projects. You can incrementally migrate VB class library projects to .NET 6 or 7.
When migrating a VB ASP.NET Framework project, a new C# ASP.NET Core project will be created. Razor (.cshtml, .razor) support in ASP.NET Core is based on C# and requires a C# project. ASP.NET Core doesn’t support VB views (.vbhtml), so they need to be manually migrated. The tool also cannot automatically migrate VB code to C#. If the amount of VB code in the ASP.NET project is large, it’s recommended to move the code to a new VB class library targeting .NET Framework and then use the new class library incremental migration experience. The migrated VB class library can then be referenced from the ASP.NET Core project.
User experience improvements
In this release, we’ve made several user experience (UX) improvements to the incremental migration tooling. We’ll briefly go over the significant updates here.
We improved the dialog for selecting whether to create a new migration project or use an existing one. You can see the improved dialog in the following image: