Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way I can customize a label that I use often?

In my Xamarin XAML I use this many times:

<Label Text="{x:Static local:FontAwesome.FACheck}" FontFamily="FontAwesome" 
   XAlign="Center" FontSize="13" 
   TextColor="#1E90FF" />

Is there a way using C# that I can create a custom version of Label and use that so I don't have to keep specifying the Font and other things?

like image 563
Alan2 Avatar asked Jul 10 '17 03:07

Alan2


People also ask

How do you customize labels in Word?

Go to Mailings > Labels. In the Address box, type the text that you want. To change the formatting, select the text, right-click, and make changes with Home > Font or Paragraph. In the Label Options dialog box, make your choices, and then select OK.

Is there a label making app?

Logolab is the most convenient logo design APP, easily and fast create stunning logos & icons for your business with just a few taps, even if you have no design experience.

What is the best way to create a label?

Canva’s drag-and-drop tool allows you to create a professional-quality label with no graphic design experience needed. With hundreds of designer-made templates, we have taken the guesswork out of spacing, formatting and font pairing—so you can focus on growing your business.

When to use labels in word?

If you use the Labels feature in Word, you may want to specify which label to use as the starting point when printing. ... When you create a document designed to be printed on a particular type of label stock, it might be helpful if Word ...

How to add custom labels to a table in Microsoft Word?

Alternatively, click inside the cell, select the Table Tools Layout tab at the top of the page, click on Select, and choose Select Cell. Copy your label using the Copy menu in your software or using a keyboard shortcut (Windows: Ctrl + C / MacOS: ⌘ + C). Next, you need to select the labels into which you will add your copied design.

What should be included in a label?

A label should include: 1 the product name 2 the company logo or icon 3 production details such as a list of ingredients 4 a short description of the product and a product story if applicable 5 design elements such as typographic pairing and white space.


2 Answers

Maybe, you can use a Style in your App.xaml.

<Application xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="YourAPp.App">
    <Application.Resources>
       <ResourceDictionary>
            <Style x:Key="FACheck" TargetType="Label">
                <Setter Property="Text" Value="{x:Static local:FontAwesome.FACheck}"/>
                <Setter Property="FontFamily" Value="FontAwesome"/>
                <Setter Property="XAlign" Value="Center"/>
                <Setter Property="FontSize" Value="13"/>
                <Setter Property="TextColor" Value="#1E90FF"/>
            </Style>
       <ResourceDictionary>
    </Application.Resources>
</Application>

And then in your pages, you just need to use it wherever you need to place this label.

<Label Style="{StaticResource FACheck}"/>

In case you want to define your resources in C#

public class App : Application
{
    public App ()
    {

            //Begin - Style code

            var faCheckStyle = new Style(typeof(Label))
            {
                Setters = {
                    new Setter { Property = Label.TextProperty,   Value = FontAwesome.FAChcek },
                    new Setter { Property = Label.FontFamilyProperty, Value = "FontAwesome" },
                    new Setter { Property = Label.XAlignProperty, Value = "FontAwesome" },
                    new Setter { Property = Label.FontSizeProperty, Value = 13 },
                    new Setter { Property = Label.TextColorProperty, Value = Color.FromHex("#1E90FF") }
                 }
            };
            Resources = new ResourceDictionary();
            Resources.Add("FACheck", faCheckStyle);      

            //End Style code
    }
    ...
}
like image 88
Jesus Angulo Avatar answered Oct 24 '22 01:10

Jesus Angulo


Create your class and use it everywhere

public class MyAwesomeLabel : Xamarin.Forms.Label
{
    public MyAwesomeLabel()
    {
        FontFamily = "FontAwesome";
        XAlign = Xamarin.Forms.TextAlignment.Center; //deprecated BTW
        FontSize = 13;
        TextColor = Color.FromHex(0x1E90FF);
        //etc
    }
}
like image 28
Yuri S Avatar answered Oct 24 '22 00:10

Yuri S