Delpin Susai Raj Thursday, 16 December 2021

Xamarin.Forms - Style Inheritance

In this blog post, you will learn how to implement Style Inheritance in Xamarin.Forms app.

Introduction

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Style Inheritance

Style inheritance is performed by setting the Style.BasedOn property to an existing Style. In XAML, this is achieved by setting the BasedOn property to a StaticResource markup extension that references a previously created Style.

Prerequisites

  • Visual Studio 2017 or later (Windows or Mac)

Setting up a Xamarin.Forms Project

Start by creating a new Xamarin.Forms project. You wíll learn more by going through the steps yourself. 

Create a new or existing Xamarin forms(.Net standard) Project. With Android and iOS Platform. 

BaseStyle

Now, I'm going to create the base style for buttons in App.Xaml

App.Xaml

Style Inheritance

RedButtonStyle

Here, I'm going to inhert base style into the RedbuttonStyle in App.Xaml. See below example

RedButtonStyle.xaml

GreenButtonStyle

Here, I'm going to inhert base style into the RedbuttonStyle in App.Xaml. See below example

GreenButtonStyle.xaml

Consume Style

Now, I'm going to consume the style into my button.

MainPage.Xaml

Run 

I hope you have understood you will learn how to implement Style Inheritance in Xamarin.Forms.

Thanks for reading. Please share your comments and feedback. 

Happy Coding :)

4 comments:

  1. Make a great name in the world of app development. Inwizards Xamarin development company is what you need to give a digital boost to your company. To get the best developers, hire xamarin developers from Inwizards.


    Why Choose Inwizards Xamarin Development Company?


    Experienced Xamarin Developers
    500+ successful projects delivered
    Mastery in latest technologies
    Transparent workflow
    Affordable
    Support and maintenance
    Diverse medium to interact with developers


    If you want to achieve success for your business, Inwizards LLC provides the best xamarin development services.

    Feel free to get in touch with us for further discussions and pricing details. Here are our contact details:

    Website Address: https://www.inwizards.com/hire-xamarin-developers.php

    Email: info@inwizards.com

    Call: USA- +1-(979)-599-0896 | IN- +91-9667584436

    ReplyDelete
  2. Make a great name in the world of app development. Inwizards Xamarin development company is what you need to give a digital boost to your company. To get the best developers, hire xamarin developers from Inwizards.

    Why Choose Inwizards Xamarin Development Company?

    Experienced Xamarin Developers
    500+ successful projects delivered
    Mastery in latest technologies
    Transparent workflow
    Affordable
    Support and maintenance
    Diverse medium to interact with developers

    If you want to achieve success for your business, Inwizards LLC provides the best xamarin development services.

    Feel free to get in touch with us for further discussions and pricing details. Here are our contact details:

    Website Address: https://www.inwizards.com/hire-xamarin-developers.php

    Email: info@inwizards.com

    Call: USA- +1- (979)-599-0896 | IN- +91-9667584436

    ReplyDelete
  3. I want you to keep providing such information, I learned something out of your knowledge, I hope to keep sharing such information thank you.
    Hotmail bellen

    ReplyDelete
  4. I want you to keep providing such information, I learned something out of your knowledge, I hope to keep sharing such information thank you.
    visit site

    ReplyDelete