XAML TIPS AND TRICKS
By Charlin Agramonte
Charlin Agramonte
charlin@crossgeeks.com
Twitter: @chard003
https://xamgirl.com/
XAML
Extended
Application
Markup
Language
Microsoft XAML vs. Xamarin.Forms
What gets created?
UI- XAML
CODE BEHIND - C#
Benefits
- Separation of UI from Behavior
- Code easier to read
:(
:)
15 Tips and tricks
Tip 1: Using String format
Before
Sample 1
Before
Sample 1
Other options
Formatted Text: More complex scenarios
Binding Formatted:
http://puresourcecode.com/dotnet/post/binding-formattedstring-for-xamarin-
forms
Tip 2: Using static properties
Before
Sample 1
1 2
3
After
Sample 1
Before
Sample 2
After
Sample 2
Tip 3: Using attached Properties
Before
Sample 1
After
Sample 1
Tip 4: Adding generic styles
Before
MyClass.xaml
Sample 1
After
App.xaml.cs
MyClass.xaml
Sample 1
More info: https://xamgirl.com/universal-styling-in-xamarin-form-apps/
Before
Sample 2
Setting the
same color in
all the pages
Before
Sample 2
Themes
Sample 3
More info:
https://docs.microsoft.com/es-es/xamarin/xamarin-forms/user-interface/them
es/
Tip 5: Using native properties
Before
Sample 1
After
Sample 2 - Fast Scrolling
More info:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/platform/platform-
specifics/consuming/
Tip 6: Simplify NameSpaces
Before
After
Tip 7: Triggers
Before
Sample 1- Property Triggers
After
Sample 1- Property Triggers
Before
Sample 2- Data Triggers
After
Sample 2- Data Triggers
Before
Sample 3- MultiTriggers
After
Sample 3- MultiTriggers
More info:
https://docs.microsoft.com/es-es/xamarin/xamarin-forms/app-fundamentals
/triggers
Tip 8: Converters
Before
After
Tip 9: Commands
Before
After
Tip 10: Using x:Reference
Before
After
More info:
https://docs.microsoft.com/es-es/xamarin/xamarin-forms/xaml/xaml-basics/
data-binding-basics
Tip 11: Line Break
Before
After
More info:
https://docs.microsoft.com/es-es/dotnet/framework/wpf/advanced/how-to-u
se-special-characters-in-xaml
Tip 12: Passing parameters
Before
After
More info:
https://docs.microsoft.com/en-us/xamarin/xamarin-forms/xaml/passing-argu
ments
Tip 13: Creating colors
Before
After
Tip 14: Fixing Extra lines in iOS
Before
Sample 1
More info:
https://xamgirl.com/quick-trick-remove-extra-separator-line-in-listview-xama
rin-forms-ios/
Tip 15: Visual State
Focused
Enabled
Disabled
References
- Xaml Tips and Tricks
https://xamgirl.com/xaml-tips-and-tricks/
THANK YOU!!!
Charlin Agramonte
charlin@crossgeeks.com
Twitter: @chard003
https://xamgirl.com/

Xaml tips and tricks