Skip to content

Instantly share code, notes, and snippets.

View sthewissen's full-sized avatar
🤷‍♂️
Developing tings.

Steven Thewissen sthewissen

🤷‍♂️
Developing tings.
View GitHub Profile
@sthewissen
sthewissen / AppTheme.cs
Created December 16, 2020 12:10
Getting/setting app theme
// Get the current theme
OSAppTheme currentTheme = Application.Current.RequestedTheme;
// Set the current theme.
Application.Current.UserAppTheme = OSAppTheme.Dark;
@sthewissen
sthewissen / AppThemeBinding.xaml
Created December 16, 2020 10:44
AppThemeBinding
<ContentPage>
<StackLayout Margin="20">
<Label Text="This text is green in light mode, and red in dark mode."
TextColor="{AppThemeBinding Light=Green, Dark=Red}" />
<Image Source="{AppThemeBinding Light=lightlogo.png, Dark=darklogo.png}" />
</StackLayout>
</ContentPage>
@sthewissen
sthewissen / TouchEff.xaml
Created November 20, 2020 14:17
A sample using basic TouchEffect properties
<Grid touch:TouchEff.PressedBackgroundColor="{StaticResource light_blue}"
touch:TouchEff.RegularBackgroundColor="{StaticResource white}"
touch:TouchEff.Command="{Binding OpenThemePickerCommand}">
...
</Grid>
@sthewissen
sthewissen / NumericKeyboardEntryRenderer.cs
Created October 6, 2020 13:49
Overriding the keyboard for specific types in Xamarin.Forms
using System.ComponentModel;
using MyProject.iOS.Renderers;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(Entry), typeof(NumericKeyboardEntryRenderer))]
namespace MyProject.iOS.Renderers
{
public class NumericKeyboardEntryRenderer : EntryRenderer
using Android.Content;
using MyProject.Controls;
using MyProject.Droid.Renderers;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using WebView = Android.Webkit.WebView;
[assembly: ExportRenderer(typeof(ExtendedWebView), typeof(ExtendedWebViewRenderer))]
namespace MyProject.Droid.Renderers
{
@sthewissen
sthewissen / PancakeBorder2.xaml
Created July 10, 2020 07:35
Pancake Border as MarkupExtension!
<yummy:PancakeView Border="{yummy:BorderMarkup Color=Orange, Thickness=10}">
...
</yummy:PancakeView>
@sthewissen
sthewissen / PancakeBorder.xaml
Created July 10, 2020 07:33
Border in a separate object!
<yummy:PancakeView>
<yummy:PancakeView.Border>
<yummy:Border Thickness="10" Color="Orange" />
</yummy:PancakeView.Border>
...
</yummy:PancakeView>
@sthewissen
sthewissen / Border.cs
Last active July 10, 2020 07:27
Simplified border API for PancakeView
public class Border
{
public int Thickness { get; set; }
public Color Color { get; set; }
public DashPattern DashPattern { get; set; }
public BorderDrawingStyle DrawingStyle { get; set; }
public Point GradientStartPoint { get; set; }
public Point GradientEndPoint { get; set; }
public GradientStopCollection GradientStops { get; set; }
}
@sthewissen
sthewissen / MainPage.xaml
Created June 29, 2020 15:01
A sample AppFrame page
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Foodie.Controls"
xmlns:pagemodels="clr-namespace:Foodie.PageModels"
x:Class="Foodie.Pages.MainPage">
<local:AppFrame x:DataType="{x:Type pagemodels:MainPageModel}" Title="Meals">
<local:AppFrame.Content>
<Grid Padding="0,16">
...
@sthewissen
sthewissen / AppFrame.xaml.cs
Created June 29, 2020 14:56
Code-behind for the AppFrame
public partial class AppFrame : Grid
{
public static readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Content), typeof(string), typeof(AppFrame), default(string));
public string Title
{
get { return (string)GetValue(TitleProperty); }
set { SetValue(TitleProperty, value); }
}