Xamarin Certification Xamarin.Forms 4 — Questions and Answers
Question 1: Which Xamarin.Forms class is used to create platform-specific code via the Dependency Service pattern?
- DependencyService (Correct answer)
- PlatformEffect
- MessagingCenter
- Device.RuntimePlatform
Correct answer: DependencyService
DependencyService resolves platform-specific implementations of shared interfaces registered with [assembly: Dependency] attributes.
Question 2: What is a Custom Renderer used for in Xamarin.Forms?
- Replacing the XAML parser with a custom one
- Overriding the native platform control generated for a Xamarin.Forms element (Correct answer)
- Providing custom animations between pages
- Creating custom XAML markup extensions
Correct answer: Overriding the native platform control generated for a Xamarin.Forms element
Custom Renderers let you subclass the platform renderer to modify or replace the native control that backs a Xamarin.Forms element.
Question 3: Which trigger type in Xamarin.Forms fires when a property on a control changes to a specified value?
- DataTrigger
- EventTrigger
- MultiTrigger
- PropertyTrigger (Correct answer)
Correct answer: PropertyTrigger
PropertyTrigger watches a single BindableProperty and applies setters when the property reaches the specified Value.
Question 4: In Xamarin.Forms, what does the [assembly: ExportRenderer] attribute do?
- Exports the renderer to be used as a shared library
- Registers a custom renderer for a specific Xamarin.Forms type in a platform project (Correct answer)
- Marks a class as available through DependencyService
- Enables the renderer to be unit tested
Correct answer: Registers a custom renderer for a specific Xamarin.Forms type in a platform project
ExportRenderer links a Xamarin.Forms control type to its custom renderer implementation in the platform-specific project.
Question 5: Which Xamarin.Forms animation method animates a view's opacity from its current value to a target value?
- view.TranslateTo
- view.ScaleTo
- view.FadeTo (Correct answer)
- view.RotateTo
Correct answer: view.FadeTo
FadeTo animates the Opacity property of a VisualElement to the specified value over a given duration.
Question 6: What is the difference between OnPlatform and OnIdiom in Xamarin.Forms XAML?
- OnPlatform targets OS (iOS/Android/UWP); OnIdiom targets device form factor (Phone/Tablet/Desktop) (Correct answer)
- OnPlatform targets device form factor; OnIdiom targets OS
- Both serve identical purposes and are interchangeable
- OnIdiom is only available in C# code-behind
Correct answer: OnPlatform targets OS (iOS/Android/UWP); OnIdiom targets device form factor (Phone/Tablet/Desktop)
OnPlatform selects values based on the operating system, while OnIdiom selects values based on the device idiom such as Phone or Tablet.
Question 7: Which Xamarin.Forms Shell feature allows grouping multiple routes under a common navigation section?
- FlyoutItem
- ShellContent
- TabBar (Correct answer)
- NavigationPage
Correct answer: TabBar
TabBar in Shell groups ShellContent items into tab-based navigation sections displayed at the bottom of the screen.
Which Xamarin.Forms class is used to create platform-specific code via the Dependency Service pattern?