Last active
January 8, 2019 13:57
-
-
Save fdervishi90/2c2a5e8ea06f7069e7c72802a4cef76d to your computer and use it in GitHub Desktop.
#xamarin #c#
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
// PCL difference between devices | |
switch (Device.RuntimePlatform) | |
{ | |
case Device.iOS: | |
Padding = new Thickness(0, 20, 0, 0); | |
break; | |
case Device.Android: | |
Padding = new Thickness(0, 20, 0, 0); | |
break; | |
case Device.UWP: | |
Padding = new Thickness(0, 20, 0, 0); | |
break; | |
} | |
// PCL difference between devices in XAML | |
// on the content page | |
<ContentPage.Padding> | |
<OnPlatform x:TypeArguments="Thickness"> | |
<On Platform="Android">0,20,0,0</On> | |
</OnPlatform> | |
</ContentPage.Padding> | |
// or on a layout | |
<StackLayout BindingContext="{x:Reference slider}" HorizontalOptions="Center"> | |
<BoxView Color="Green" Opacity="{Binding Value}"></BoxView> | |
<Label x:Name="label" Text="{Binding Value, StringFormat='Value is {0:F2}'}" Opacity="{Binding Value}" /> | |
<Slider x:Name="slider"></Slider> | |
<StackLayout.Padding> | |
<OnPlatform x:TypeArguments="Thickness"> | |
<On Platform="iOS">0</On> | |
<On Platform="Android">0,20,0,0</On> | |
</OnPlatform> | |
</StackLayout.Padding> | |
</StackLayout> | |
// Enable XAML compilaton during build time, default is "Skip" | |
[assembly: XamlCompilation(XamlCompilationOptions.Compile)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment