Skip to content

Instantly share code, notes, and snippets.

Avatar
🐼
Thinking

S.Tuğçe Arar stugcearar

🐼
Thinking
View GitHub Profile
@stugcearar
stugcearar / gist:a0bf9eaa92925e77da2141f2209cc15c
Created Feb 5, 2017 — forked from brianmed/gist:4e458d9116889b798a8c
Xamarin Forms custom webView renderer with activity load
View gist:a0bf9eaa92925e77da2141f2209cc15c
***
In Shared code:
public class WebViewPage : ContentPage
{
}
...
await Navigation.PushAsync (new WebViewPage());
View slider.xaml
<StackLayout VerticalOptions="Center">
<Label x:Name="lblText" Text="0" HorizontalOptions="Start" FontSize="Micro" HorizontalTextAlignment="Center" VerticalOptions="EndAndExpand" >
<Label.Margin>
<OnPlatform x:TypeArguments="Thickness">
<On Platform="iOS" Value="15,0" />
<On Platform="Android" Value="10,0" />
</OnPlatform>
</Label.Margin>
</Label>
<Slider x:Name="mySlider" Maximum="10000" Minimum="100" HorizontalOptions="FillAndExpand" ValueChanged="Handle_ValueChanged" >
View EmptyCollectionContractResolver.cs
class EmptyCollectionContractResolver : DefaultContractResolver {
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) {
JsonProperty property = base.CreateProperty(member, memberSerialization);
Predicate<object> shouldSerialize = property.ShouldSerialize;
property.ShouldSerialize = obj => (shouldSerialize == null || shouldSerialize(obj)) && !IsEmptyCollection(property, obj);
return property;
}
private bool IsEmptyCollection(JsonProperty property, object target) {
View LayoutPage.xmal
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.LayoutPage">
<ContentPage.Content>
<StackLayout>
<Image Source="icon.png" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
View slider.cs
void Slider_ValueChanged(object sender, Xamarin.Forms.ValueChangedEventArgs e)
{
var newStep = Math.Round(e.NewValue / 100);
mySlider.Value = newStep * 100;
lblText.Text = mySlider.Value.ToString();
lblText.TranslateTo(mySlider.Value * ((mySlider.Width - 40) / mySlider.Maximum) , 0, 100);
}
@stugcearar
stugcearar / Badge.cs
Created Apr 11, 2018 — forked from rudyryk/Badge.cs
C# — Xamarin.Forms custom simple badge view + rounded box view via custom renderer
View Badge.cs
//
// Badge.cs
// Created by Alexey Kinev on 19 Jan 2015.
//
// Licensed under The MIT License (MIT)
// http://opensource.org/licenses/MIT
//
// Copyright (c) 2015 Alexey Kinev <alexey.rudy@gmail.com>
//
using System;
View ListViewPageViewModel.cs
public class ListViewPageViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName]string propertyName = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
private IList<Birds> birdsList;
bool isRefreshing;
private bool isEmpty;
public bool IsEmpty
View Birds.cs
public class Birds
{
public string Title { get; set; }
public string Description { get; set; }
}
View Converter.cs
public class Converter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return !(bool)value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return !(bool)value;
}
View EmptyView.xaml
<ContentView.Content>
<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
<Image Source="empty.png"/>
<Label Text="There is nothing in here." FontSize="Medium" TextColor="{DynamicResource TextColorLight}"/>
</StackLayout>
</ContentView.Content>
You can’t perform that action at this time.