New Features in Xamarin.Forms 4.8: Gradients, Brushes, and Flyout Backdrop Color | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (174).NET Core  (29).NET MAUI  (207)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (215)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (915)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (147)Chart  (131)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (628)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (507)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (592)What's new  (332)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
New Features in Xamarin.Forms 4.8 :Gradients, Brushes, and Flyout Backdrop Color

New Features in Xamarin.Forms 4.8: Gradients, Brushes, and Flyout Backdrop Color

Our world is constantly evolving, and the technology field has seen some of the biggest changes. Further proof of this arrived on August 7, when Xamarin.Forms was updated again. Now, we have version 4.8, which delivered a collection of features that allow developers to create more interactive and attractive applications.

In this article, I am going to focus on two features available in the new Xamarin.Forms 4.8 release:

Let’s get started!

Gradients and brushes

In order to paint an area in our application, we have to use a brush. Brushes come in different types to produce different outputs.

The types of brushes available are:

  • Solid Colors
  • Linear Gradients
  • Radial Gradients

Solid colors

The solid color brush allows us to paint an area with a solid color, as its name indicates. Here is an example using XAML code.

<Frame Background="DarkGreen"
       BorderColor="DarkGreen"
       HasShadow="True"
       CornerRadius="12"
       HeightRequest="120"
       WidthRequest="120"/>

This XAML produces the following output.

Solid Colors
Source: Vicente Guzman on GitHub

Linear gradient

The linear gradient brush allows us to combine two or more colors in a gradient. See the green to yellow linear gradient in the following screenshot.

Linear Gradients
Source: Vicente Guzman GitHub

To use the linear gradient, we need to know where to use the StartPoint and EndPoint properties. If we want to implement the gradient in the previous screenshot, we would code it as follows.

<Frame BorderColor="DarkGreen"
       HasShadow="True"
       CornerRadius="12"
       HeightRequest="120"
       WidthRequest="120">
       <Frame.Background>
              <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
               <GradientStop Color="Green" Offset="0.1"/>
               <GradientStop Color="Orange" Offset="1.0"/>
              </LinearGradientBrush>
       </Frame.Background>
</Frame>

Radial gradient

The last type of brush now available in Xamarin.Forms 4.8 is the radial gradient, which allows us to mix two or more colors in a gradient with a circular shape. Like the previous gradient, this one requires us to determine two properties: Center to specify the location of the center of the gradient, and Radius to determine the size of the radius of the gradient.

The following code example creates a radial gradient with green in the middle, changing to yellow on the edges.

<Frame BorderColor="DarkGreen"
       HasShadow="True"
       CornerRadius="12"
       HeightRequest="120"
       WidthRequest="120">
       <Frame.Background>
         <RadialGradientBrush Center="0.5,0.5" Radius="0.5">
               <GradientStop Color="DarkGreen" Offset="0.1"/>
               <GradientStop Color="Yellow" Offset="1.0"/>
         </RadialGradientBrush>
       </Frame.Background>
</Frame>

This  code example produces the output shown in the following screenshot.

Radial Gradient
Source: Vicente Guzman GitHub

Flyout backdrop color

Many applications feature a drop-down menu that is accessed through a hamburger icon. In previous versions of Xamarin.Forms, we did not have the ability to edit the appearance of the menu when opening and closing it. We had to use the device’s default design as provided by the operating system.

Thanks to Xamarin.Forms 4.8, we can now easily customize the appearance of the menu in our application with the flyout backdrop color feature.

The following GIF shows the flyout backdrop color feature in action.

Flyout Backdrop Color
Source: Vicente Guzman GitHub

If you’re wondering whether we can combine the flyout backdrop color feature with the brushes and gradients discussed previously, the answer is yes! All we have to do is define a brush and assign its values to the property Shell.FlyoutBackdrop. Here is an example:

<FlyoutItem Route="stores"
            FlyoutDisplayOptions="AsMultipleItems">
        <Shell.FlyoutBackdrop>
          <LinearGradientBrush StartPoint="0,0"
                               EndPoint="1,1">
              <GradientStop Color="#8A2387"
                            Offset="0.1" />
              <GradientStop Color="#E94057"
                            Offset="0.6" />
              <GradientStop Color="#58ADF4"
                            Offset="1.0" />
          </LinearGradientBrush>
      </Shell.FlyoutBackdrop>

      <ShellContent Route="stores" 
            ContentTemplate="{DataTemplate views:NationalPage}" />
</FlyoutItem>

You can find examples of these new features in Xamarin.Forms 4.8 on GitHub:

More information about these features is available in Microsoft’s documentation:

Conclusion

In this blog, we have learned about two new colorful features in Xamarin.Forms 4.8: gradients and brushes, and the flyout backdrop color. These features help us design elegant, attractive UIs in our applications.

So, let’s build charming Xamarin.Forms applications with these new features!

Syncfusion offers over 150 UI controls for Xamarin, from basic editors to powerful, advanced controls like DataGrid, Charts, ListView, and RTE. Use them to boost your productivity!

For current Syncfusion customers, the latest version is available for download from the License and Downloads page. If you are not yet a Syncfusion customer, you can try our 30-day free trial to check out all the available features. Also, check out our samples at this GitHub location.

If you want to send us feedback, please use the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

If you liked this post, we think you’ll also like the following:

Tags:

Share this post:

Comments (1)

Is necessary add Brush_Experimental flag with newest Xamarin Forms version (4.8.0.1451)

Comments are closed.

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed