XAM1 - Forms Flashcards
What converts a View to platform specific control?
- Renderers
What are types of Forms layouts?
- StackLayout
- GridLayout
- AbsoluteLayout
- RelativeLayout
- also ScrollView
What can Margin property be added to?
- all Views
- define new Thickness(L, T, R, B)
How can you execute different values on different platforms?
- Device.OnPlatform
- in code you can also check Device.OS and Device.Idiom (enum = TargetIdiom.Tablet)
What are steps to setup an abstraction to platform specific code?
- define interface in PLC
- provide plat spec implementations
- use Dependency attribute
- retrieve dependency in shared code using DependencyService.Get
What is the syntax of the dependency attribute?
- [assembly:Dependency(typeof(PhoneDialIOS))]
- this gets registered with dependency service
The Grid.Column and Grid.Row are examples of what?
- attached properties
What are requirements for you to be able to set a property in XAML?
- must be public
- must have a setter
What is x: namespace?
- common across all XAML platforms
- make common XAML keywords available to parser
How do you access XAML elements in code?
- add x:Name which adds private fields
- must be unique and confirm to variable naming conventions
- not available until after InitializeComponent() runs
Event handlers in XAML?
- can be done, not recommended due to separation of concerns
- event handlers in XAML can be public, private or protected
- ex TextChanged=”OnTextChanged”
How can you share values in XAML?
- ResourceDictionary
- accessing via x:StaticResource
What is XamlCompilation?
- can be applied at class or namespace level
- compiles XAML into IL
- performs compile time checking of XAML
- lowers file size
- removes some object instantiation time
How can you re-use XAML views?
- use ContentView
How are rendered control sizes figured?
- Layouts asks children how much space they request by calling Measure method
- child View responds with preferred size
- layout panel calls layout method on child view
- cycle repeats as needed
View positioning are controlled by what?
- WidthRequest and HeightRequest
- also VerticalOptions and HorizontalOptions of containers
Vertical/HorizontalOptions default to what?
- FILL
Is Margin available on all Views?
- YES
- Padding only available on layout views
What does StackLayout consist of?
- IList called Children
- the order matters
What is StackLayout default Orientation?
- Vertical
How are attached properties implemented?
- with BindableProperty and BindableObject