Câu hỏi phỏng vấn Xamarin
Câu hỏi

How many types of different XAM...

Câu trả lời

XAML Markup Extensions are a powerful feature in XAML that allow developers to set element properties from sources other than literal text strings. They enhance the flexibility and functionality of XAML by enabling dynamic and complex property assignments. Here are some of the different types of XAML Markup Extensions commonly used:

  1. x:Static: This extension is used to assign static property values to XAML element properties. It references static fields or properties from code.

    xaml Copy
    <Label Text="{x:Static local:AppConstants.DefaultName}" />
  2. x:Reference: This extension allows you to reference another element in the XAML by its name.

    xaml Copy
    <Label Text="{x:Reference Name=otherElement}" />
  3. x:Type: This extension is equivalent to the C# typeof keyword and is used to get the Type object of a class or structure.

    xaml Copy
    <Setter Property="TargetType" Value="{x:Type Button}" />
  4. x:Array: This extension enables the definition of arrays in XAML. It requires a Type attribute to specify the type of elements in the array.

    xaml Copy
    <x:Array Type="{x:Type Color}">
        <Color>Red</Color>
        <Color>Green</Color>
        <Color>Blue</Color>
    </x:Array>
  5. x:Null: This extension is used to set a property to null.

    xaml Copy
    <Label Text="{x:Null}" />
  6. OnPlatform: This extension allows you to set different values for a property based on the platform (e.g., iOS, Android).

    xaml Copy
    <Button BackgroundColor="{OnPlatform iOS=Red, Android=Green, Default=Blue}" />
  7. OnIdiom: This extension allows you to set different values for a property based on the device type (e.g., Phone, Tablet).

    xaml Copy
    <Label FontSize="{OnIdiom Phone=12, Tablet=18}" />
  8. Binding: This extension is used for data binding, linking a property of a UI element to a data source.

    xaml Copy
    <Label Text="{Binding Path=Name}" />
  9. StaticResource: This extension is used to reference a resource defined in a resource dictionary.

    xaml Copy
    <Label Text="{StaticResource myResource}" />
  10. DynamicResource: Similar to StaticResource, but it updates the property value if the resource changes at runtime.

    xaml Copy
    <Label Text="{DynamicResource myResource}" />
  11. TemplateBinding: This extension is used within control templates to bind to properties of the templated parent.

    xaml Copy
    <TextBl...
senior

senior

Gợi ý câu hỏi phỏng vấn

middle

What is Behaviors? Give some examples where we should use Behaviors?

middle

What is ViewCell and How many types of built-in Cells are available?

junior

How will you navigate from one page to another?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào