19 CEO Dashboard Examples for Business Leaders
Let's rewind to the 1990s. Data used to be stored on servers and CEOs relied on basic tools to make optimal decisions. No dashboards, nothing. When you use Power BI with a solid...
Kapil Panchal - December 11, 2020
Listening is fun too.
Straighten your back and cherish with coffee - PLAY !
Predefined and used all over the application is called Application theme. In various popular apps like YouTube, Skype, WhatsApp, Instagram, etc. is providing themes like Light, dark mode to the user. We can change the color of the application using themes by a predefined set of a color scheme like dark, light, or any other color.
We can create a theme using Resources, ResourceDictionary, and Styles in Xamarin Forms. Resources are commonly shared values in the application. It is responsible for the reusability of values that highly scale. It reduces the hard code values in the application, so when we have to change the theme we have to change only a defined set of resources only. We do not have to change all the values.
ResourceDictionary is a group of resources. Resources are stored in ResourceDictionary. In a single ResourceDictionary, we can add multiple resources. We will find ResourceDictionary in App.XAML file.
Styles means assigning various properties to the UI Control for a better look and feel. We can use these defined styles all over the application to give the same look to the application. We do not have to write code on every page for the same control to give the same look in the app we can define a style for that control and bind the style where ever it is needed. Styles are defined in the app. XAML file. Each style has a unique key and target type.
We can define style in App.xaml file in the following way and display in the Xaml page inside the control.
Applying style to Label
Let's see the example of applying a theme.
We will be going to create a simple application in which we will apply Light and Dark mode to the application. By default, we will set the theme as Light.
First, we will create a theme using ResourceDictionary and then set a default theme using ResourceDictionary in App.Xaml file.
Code for Light Mode
White WhiteSmoke WhiteSmoke Black blue White Gray Transparent
CS file
public partial class LightTheme : ResourceDictionary { public LightTheme() { InitializeComponent(); } }
Code for Dark Mode
Black Gray Skyblue White White White WhiteSmoke Transparent
CS File
public partial class DarkTheme : ResourceDictionary { public DarkTheme() { InitializeComponent(); } }
Now, we will set Light mode as default and add style for UI control we are going to use in our application.
Now, we will create View pages that are one for changing the theme and the other two display detail and summary.
This code is for changing the theme of the app, and the second code is a cs file for a select theme.
Image: Theme selection page
Code for Summary and detail page.
CS file
public partial class UserSummaryPage : ContentPage { public UserSummaryPage() { InitializeComponent(); } async void OnNavigation(object sender, EventArgs e) { await Navigation.PushAsync(new UserDetailsPage()); } async void OnThemeToolbarItemClicked(object sender, EventArgs e) { await Navigation.PushModalAsync(new NavigationPage(new ThemeSelectionPage())); } }
Image: Summary page (Light Mode)
Image: Summary (Dark mode)
Code for detail page
Cs file
public partial class UserDetailsPage : ContentPage { public UserDetailsPage() { InitializeComponent(); } async void OnThemeToolbarClicked(object sender, EventArgs e) { await Navigation.PushModalAsync(new NavigationPage(new ThemeSelectionPage())); } }
Image: Detail page (Light Mode)
Image: Detail page (Light Mode)
In this blog we have learned about what is themes in Xamarin forms and how we can apply to the application. Using ResourceDictionary and Styles we can create and apply themes. We have seen an example in which we have change the theme from light to dark mode dynamically. We have created two ResourceDictionary for both modes and set Light mode as default in app.xaml file.
Build Your Agile Team
Let's rewind to the 1990s. Data used to be stored on servers and CEOs relied on basic tools to make optimal decisions. No dashboards, nothing. When you use Power BI with a solid...
Imagine walking into a meeting where critical decisions need to be made—fast. You need clear, flexible data that you can analyze on the spot. But what if your insights are locked inside...
Clear insights mean smarter decisions, and this is what data storytelling does. It helps you speak a language that you quickly understand. Like for example, you are a CTO dealing with...