Skip to content

Instantly share code, notes, and snippets.

View shawyunz's full-sized avatar
🚀
Crafting Brilliance w/ .NET

Shaw Yu shawyunz

🚀
Crafting Brilliance w/ .NET
View GitHub Profile
//from https://hackernoon.com/please-dont-use-offset-and-limit-for-your-pagination-8ux3u4y
//BAD
SELECT + FRM table_name LIMIT 10 OFFSET 40
//GOOD
SELECT + FRM table_name WHERE id > 40 LIMIT 10
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
//MyEntryRenderer : EntryRenderer
//for android
if (Control != null)
{
Control.SetBackgroundColor(global::Android.Graphics.Color.LightYellow);
Control.SetCursorVisible(false);
Control.SetPadding(0, 0, 0, 0);
Control.Gravity = GravityFlags.CenterVertical | GravityFlags.Left;
}
@shawyunz
shawyunz / OnPlatform samples.txt
Last active May 12, 2020 20:52
Attributes for cross-platform
//XAML
WidthRequest = "{x:OnPlatform Android=20, iOS=15, Default=20}"
Source = "{x:OnPlatform iOS='icon1.png', Android='icon2.png'}"
<OnPlatform x:Key="color" x:TypeArguments="x:String">
<On Platform="Android" Value="Red" />
<On Platform="iOS" Value="Orange" />
</OnPlatform>
//CSharp
@shawyunz
shawyunz / LabelFA.xaml
Last active March 19, 2020 22:09
Sample of font awesome in xamarin forms
<Label
Text="&#xf578;"
FontFamily="fa5_solid.otf#fa-solid"
FontSize="20" />
@shawyunz
shawyunz / LocalStyleSample.xaml
Last active March 24, 2020 03:49
ui style in local layout #Xamarin.Forms #ResourceDictionary
<StackLayout.Resources>
<ResourceDictionary>
<Style TargetType="Label">
<Setter Property="HorizontalOptions" Value="End" />
</Style>
</ResourceDictionary>
</StackLayout.Resources>
@shawyunz
shawyunz / FabAnimation.cs
Last active March 24, 2020 03:50
floating action menu #animation #fab #Xamarin.Forms
BtnTop.TranslateTo(0, -70),
BtnTop.FadeTo(1),
BtnLeft.TranslateTo(-70, 0),
BtnLeft.FadeTo(1),
ActionBtn.FadeTo(0.4)
@shawyunz
shawyunz / StyleXAML(Shaw)
Last active March 19, 2020 22:11
Get inspiration from Sharpnado's blog and made some customization for StyleXAML setting #XAML #XAML.Styler #Xamarin.Forms
/*
x:Class
xmlns, xmlns:x, xmlns:d, xmlns:mc, mc:Ignorable, xmlns:*
x:Key, Key, x:Name, Name, x:Uid, Uid, Title
x:TypeArguments, x:DataType, x:*
BindingContext, TabIndex
Grid.Row*, Grid.Column*, RowSpacing, ColumnSpacing, AbsoluteLayout.LayoutFlags, AbsoluteLayout.LayoutBounds
IsVisible
Style*
WidthRequest, HeightRequest, MinimumWidthRequest, MinimumHeightRequest, M*Width, M*Height
@shawyunz
shawyunz / MethodAccessException
Last active January 22, 2020 21:27
```System.MethodAccessException: Method Xamarin.Forms.View:.xxxx ()' is inaccessible from method App.InitializeComponent ()'.``` Add "this" to constructor method
this.InitializeComponent ();
@shawyunz
shawyunz / FirstInList.cs
Last active March 24, 2020 03:51
For select result in linq, First or FirstOrDefault #linq #csharp
//case 1: First
try
{
var result1 = List.First(x => x == "foo");
}
catch (Exception)
{
//catch
}