This is my new article for Xamarin Forms Designer. If you are using Xamarin Forms Designer, I hope this will save you some time. In this article, we will learn how to use test data while designing your UI to see how your UI look like without much effort.
New Xamarin.Forms provides a solution for faster design and preview of your UI, i.e., XAML Previewer. The XAML Previewer allows you to preview of your dummy data at design time. You don't need to build, compile, and deploy your app to see the UI output.
Here is 3 lines of code that you placed in XAML namespace.
- xmlns:d="http://xamarin.com/schemas/2014/forms/design"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d"
After adding this namespace, you can use “d:” for the dummy data. For example, d:Text=”ABCD!”. With this attribute on a control, the control will be displayed in XAML Previewer.
NOTE
Element with d: do now show at the run time.
Element with d: do now show at the run time.
Requirements
(XAML Previewer) Design time data requires a minimum version of Xamarin.Forms 3.6 or later.
Example
- <StackLayout d:Padding="0,20">
- <Label d:Text="This is Design time test data"
- d:TextColor="Red"
- HorizontalOptions="Center"
- VerticalOptions="CenterAndExpand" />
- </StackLayout>

You can use any Xamarin Forms attribute like control, Fontsize, TextColor, Spacing any control or the property you can use with this “d:”, this will be shown in design preview only.
Another Example



Join the conversation! Your thoughts help the community grow.