Last active
August 29, 2015 14:10
-
-
Save tombowers/9119f7f240170a769d14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomAndroidEntryRenderer : EntryRenderer | |
{ | |
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e) | |
{ | |
base.OnElementChanged(e); | |
if (e.OldElement == null) { | |
// Get the 'native' control | |
var nativeTextField = (EditText)Control; | |
nativeTextField.Text = "Ahoy there from Android!"; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new CustomEntry | |
{ | |
Text = "Space Pants" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomEntry : Entry {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomIOSEntryRenderer : EntryRenderer | |
{ | |
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e) | |
{ | |
base.OnElementChanged(e); | |
if (e.OldElement == null) { | |
// Get the 'native' control | |
var nativeTextField = (UITextField)Control; | |
nativeTextField.Text = "Ahoy there from iOS!"; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" ?> | |
<ContentPage | |
xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
xmlns:local="clr-namespace:CustomEntryRenderer;assembly=YourAssembly" | |
x:Class="CustomEntryRenderer.MainPageXaml"> | |
<StackLayout | |
VerticalOptions="CenterAndExpand" | |
HorizontalOptions="CenterAndExpand"> | |
<Label Text="Hello, Custom Renderer!" /> | |
<local:CustomEntry Text="In Shared Xaml" /> | |
</StackLayout> | |
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainPage : ContentPage | |
{ | |
public MainPage() | |
{ | |
Content = new StackLayout | |
{ | |
Children = | |
{ | |
new Entry | |
{ | |
Text = "Ahoy there!" | |
}, | |
new Button | |
{ | |
Text = "Login", | |
TextColor = Color.White, | |
BackgroundColor = Color.FromHex("77D065") | |
} | |
}, | |
VerticalOptions = LayoutOptions.CenterAndExpand, | |
HorizontalOptions = LayoutOptions.CenterAndExpand | |
}; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[assembly: ExportRenderer(typeof (CustomEntry), typeof(CustomEntryRenderer))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment