UI, Xamarin

Handling strings in our XAML’s

In this article, I just covered a few recollections of some simple but important topics to improve our Xaml’s and that are too needed and to useful in everyday life to develop an application. I hope these topics are useful for you. Let’s start! 😎

We will be learning the following topics:

✔ Concatenating strings

✔ Adding special characters to the texts

✔ Making multiple designs in the same label

✔ Displaying the telephonic Keyboard

Concatenating strings

One of the most important things at the time to develop an application is taking care with the performance, while more elements are added, more are affected. That’s why, in this article, we are going to learn how to concatenate strings in our Xaml’s, avoiding to declare more graphic controls than needed in our XAML file.

It’s simple, you just have to add a String.Format, next to the index number inside parenthesis { }, as I show below. More information about String.Format here.

🤔 Adding special characters to the texts 

Often, we need to add texts with special characters in our XAML elements, but the implementation fails.  So, how can we get it? Now, let’s learn how to do it. Here I just show some special characters codes with which we can fix it.

🔹  <   –   Less than                  –   &lt;

🔹  >   –   Greater than sign    –  &gt;

🔹  &   –  Ampersand              –  &amp;

🔹    –   Quotation mark      –  &quot;

🔹  ‘   –   Apostrophe               –  &apos;

Let’s add an example

🖌 Making multiple designs in the same label

Sometimes, we need to make friendlier the text of the label, applying different colors, sizes, font family among other styles in the same line. Is too simple! Let’s do it!

You just have to implement the following structure:

Here the example displayed below

📞 Displaying the telephonic keyboard

To add the telephonic keyboard you just have to call the Keyboard property with the Telephone value and your keyboard will display only with this type. With that way you just handle telephone entries. 😉

Good luck with your implementation 😎

Spanish post:  https://medium.com/@reyes.leomaris/manejando-string-en-nuestros-xamls-bf58a8822654




Tagged ,

Leave a Reply

Your email address will not be published. Required fields are marked *