You are on page 1of 7

Enterprise Mobility Management (EMM)

- VM-Ware: AirWatch
- MicroSoft: InTune
Apple: TestFlight
Xamarin: HockeyApp
===================
Pages, Layouts, Views, Cells
++++++++++++++++++++
Pages: VisualElements, IPageCntrol
- ContentPage,
- MasterDetailPage
- TabbedPage
- NavigationPage,
- CarouselPage
++++++++++++++++++++
Layouts: Layout<View>
- StackLayouts,
- AbsoluteLayout,
- RelativeLayouts,
- Grid,
- ContentView,
- ScrollView,
- Frame
++++++++++++++++++++
View: VisualElements
- Image,
- Label,
- ListView,
- OpenGLView,
- Picker,
- ProgressBar,
- SearchBar,
- Slider,
- Stepper,
- TableView,
- TimePicker,
- WebView
++++++++++++++++++++
Cells
- EntryCell
- SwitchCell
- TextCell
- ImageCell
===================
Custom Renderer
++++++++++++++++++++

public enum StyleType {


None,
Bold,
Italic,
BoldItalic
}
public class StyledLabel : Label
{
public StyleType Style {get; set;
}

using Android.Graphics;
using Customization.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(StyledLabel), typeof(StyledLabelRenderer ))]

namespace Customization.Droid
{
public class StyledLabelRenderer : LabelRenderer {
protected override void OnElementChanged(
ElementChangedEventArgs <Label> e ) {
base.OnElementChanged( e );
var styledLabel = (StyledLabel)Element;
switch (styledLabel.Style) {
case StyleType.Bold:
Control.SetTypeface(null, TypefaceStyle.Bold);
break;
case StyleType.Italic:
Control.SetTypeface(null, TypefaceStyle.Italic);
break;
case StyleType.BoldItalic:
Control.SetTypeface(null, TypefaceStyle.BoldItalic);
break;
}
}
}
}

++++++++++++++++++++
PCL: Accessing Native Features
++++++++++++++++++++
Use Dependency Service - i.e. dependency injection (DI) or inversion
of control (IoC)

1. Define an interface:

public interface ISomeService


{
void PerformActivity( );
}

1.1 Retrieval :
var service = DependencyService.Get<ISomeService>( );
service.PerformActivity();

2. Implement that interface on each platform:


iOS :
public class Service_iOS : ISomeService
{
 public void PerformActivity( ) {
// Native iOS implementation
}
}

Android :
public class Service_Android : ISomeService {
public void PerformActivity( ) {
 // Native Android
implementation
}
}

3. Register the implementation with Dependency Service:


[assembly: Xamarin.Forms.Dependency(typeof(Service_iOS))]
[assembly: Xamarin.Forms.Dependency(typeof(Service_Android))]

by placing the above attributes outside of the namespace declarations in


each platform in order to take effect.

Retrieval :
var service = DependencyService.Get<ISomeService>( );
service.PerformActivity();
++++++++++++++++++++
XAML Data Binding using markup extension

BindingContext is a special property of Bindable Objects. All


Xamarin.Forms objects are subclasses of BindableObject.

++++++++++++++++++++
1. Define Data Binding using XAML markup extension:
<?xml version="1.0" encoding="utf-8" ?>

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="…" x:Class="…">
<StackLayout>
<Button Text="Click Me" Clicked="Button_Clicked" />
<Label Text="{Binding LabelText}" />
<Entry Text="{Binding EntryText}" />
</StackLayout>
</ContentPage>


2. Drive from INotifyPropertyChanged interface:
public interface INotifyPropertyChanged
{
event PropertyChangedEventHandler PropertyChanged;
}
to implement PropertyChangedEventHandler event and handler:

You might also like