Forum Xamarin.Forms

What is the best way to format text in Xamarin.Forms?

EricGrahamMacEachernEricGrahamMacEachern CAMember ✭✭
edited January 2017 in Xamarin.Forms

I am converting a website into an app. This is what one of the website's pages looks like:!airway-fire/c1gxc

This is what my code looks like:

using System;
using Xamarin.Forms;

namespace FormsGallery
    class AirwayFire : ContentPage
        public AirwayFire()
            Label header = new Label
                Text = "Airway Fire",
                FontSize = 50,
                FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center

            ScrollView scrollView = new ScrollView
                VerticalOptions = LayoutOptions.FillAndExpand,
                Content = new Label
                    Text = "Management\n\n" +

"Inform team & call for help" +
"Simultaneously remove the endotracheal tube (ETT) & stop gases/disconnect circuit" +
"Pour saline or water into airway" +
"Remove airway foreign bodies (ie: ETT pieces, sponges)" +
"When fire is extinguished: re-establish ventilation; avoid supplemental oxygen if possible" +
"Consider prompt reintubation prior to swelling & coordinated with bronchoscopy" +
"Examine entire airway (including bronchoscopy) to assess injury & remove residual debris" +

"Prevention\n\n" +

"For high risk procedures:\n" +
"Discuss fire prevention & management with team during time-out" +
"Avoid FiO2 > 0.3 & avoid N2O" +

"For laser surgery of vocal cord or larynx:\n" +
"Use laser resistant ETT (single or double cuff)" +
"Assure ETT cuff sufficiently deep below vocal cords" +
"Fill proximal ETT cuff with methylene blue-tinted saline (acts as a marker if cuff perforated by laser)" +
"Ensure laser in STANDBY when not in active use" +
"Surgeon protects ETT cuff with wet gauze" +
"Surgeon confirms FiO2 < 0.3 & no N2O prior to laser use (may require several minutes to dilute FiO2 & FeO2 to <0.3 depending on fresh gas flow & initial FiO2)" +

"For non-laser surgery in oropharynx:\n" +
"Regular PVC ETT may be used" +
"Consider packing wet gauze around ETT to minimize O2 leakage" +
"Consider continuous suctioning of the operating field inside oropharynx",

                    FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),

            // Build the page.
            this.Content = new StackLayout
                Children =

This text looks really unformatted. How do I add bullet points, indents, and other features? Should I use XAML or just plain C# code.

Best Answer


  • JohnHardmanJohnHardman GBUniversity admin

    @EricGrahamMacEachern - You've probably thought of this and decided against it, but just in case - if your app will always be expected to have connectivity, could you not just use a WebView that makes use of your existing website, or if your app won't always have connectivity, could you not just grab as much of the HTML etc as possible and move that to local files that are opened in a WebView? That way, as long as your website is responsive, you'll be able to reuse existing stuff.

    If that won't work for your app, whether you use XAML or C# depends on your way of working. If you are working with a UI designer who can create XAML whilst you do the coding, it would make sense to use XAML for the UI. Many people prefer to use XAML for the UI even if they aren't splitting the work between people. I have to admit that I am using C#, but that's down to preferring using one language so that analysis tools work across as much code as possible, and a simple preference for C#.

  • Alejandro-lAlejandro-l JPMember ✭✭

    With XAML you can always add C# in your partial class, so I would say XAML.

    Indents - > Play with Padding and Margin properties.
    Bullets -> StackLayout, Grids, etc.
    Resources.resx -> try to get your texts from there and after that use string.Format()

  • ChaseFlorellChaseFlorell CAInsider, University mod

    bullets can be done in XAML on a label too.

    &#8226; Item 1
    &#8226; Item 2
    &#8226; Item 2
Sign In or Register to comment.