Skip to content

Instantly share code, notes, and snippets.

Avatar

Gerald Versluis jfversluis

View GitHub Profile
View gist:538d11caf1fe27cc3360e84a19f01931
// MainPage.xaml.cs
public RowDefinitionCollection MyRows { get; set; }
public MainPage()
{
InitializeComponent();
// Magic happening here
MyRows = (RowDefinitionCollection)new RowDefinitionCollectionTypeConverter().ConvertFromInvariantString("Auto, 100, *, 50");
@jfversluis
jfversluis / gist:b90f424e57c111e2559b55248a3d25a0
Last active Jul 31, 2020
Bindable RowDefinitions in Xamarin.Forms Grid
View gist:b90f424e57c111e2559b55248a3d25a0
// MainPage.xaml.cs
public RowDefinitionCollection MyRows => new RowDefinitionCollection() {
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = 100 },
new RowDefinition { Height = GridLength.Star },
new RowDefinition { Height = 50 },
};
public MainPage()
@jfversluis
jfversluis / dotnet-format-action.yml
Created Jul 25, 2020 — forked from rickyah/dotnet-format-action.yml
Runs dotnet-format on every PR and create a commit that fixes the formatting if it doesn't comply with your code convention
View dotnet-format-action.yml
name: Format check on pull request
on: pull_request
jobs:
dotnet-format:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2.2.0
with:
fetch-depth: 0
@jfversluis
jfversluis / NoBounceRenderer.cs
Created Jul 10, 2020
Disable bounce effect on Xamarin.Forms CollectionView
View NoBounceRenderer.cs
using System;
using CollectionViewBounceSample.iOS;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(CollectionView), typeof(NoBounceRenderer))]
namespace CollectionViewBounceSample.iOS
{
public class NoBounceRenderer : CollectionViewRenderer
{
@jfversluis
jfversluis / regexnamedgroups.cs
Last active Jul 9, 2020
Using Regex Named Groups in C#
View regexnamedgroups.cs
var azureDevOpsUrl = "https://dev.azure.com/jfversluis";
var resultUrl = "";
var azureDevOpsMatch = Regex.Match(azureDevOpsUrl, "(?<protocol>http[s]?://)(?<domainandpath>dev.azure.com/(?<accountname>[a-zA-Z]*)(.*))", RegexOptions.IgnoreCase);
if (azureDevOpsMatch.Success)
{
resultUrl = $"{azureDevOpsMatch.Groups["protocol"]}{azureDevOpsMatch.Groups["accountname"]}@{azureDevOpsMatch.Groups["domainandpath"]}";
}
Console.WriteLine(resultUrl);
View MainPage.xaml
<?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:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="CastRadio.MainPage" xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core" ios:Page.UseSafeArea="true">
<StackLayout>
<Entry Text="{Binding CastUrl, Mode=TwoWay}" />
<Button Text="Cast" Command="{Binding StartCastCommand}" />
<ListView MinimumHeightRequest="100" SelectionMode="Single" ItemsSource="{Binding CastDevices}" SelectedItem="{Binding SelectedCastDevice}">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell Text="{Binding FriendlyName}" />
</DataTemplate>
View MainPage.cs
public partial class MainPage : ContentPage
{
public string CastUrl { get; set; } = "https://icecast-qmusicnl-cdp.triple-it.nl/Qmusic_nl_live_32.aac";
public ObservableCollection<IReceiver> CastDevices { get; set; }
public IReceiver SelectedCastDevice { get; set; }
public Command StartCastCommand { get; set; }
public MainPage()
@jfversluis
jfversluis / SimplifiedGrid.xaml
Created Jun 4, 2020
Simplified Xamarin.Forms Grid definition
View SimplifiedGrid.xaml
<Grid ColumnDefinitions="1*, 2*, Auto, *, 300" RowDefinitions="1*, Auto, 25, 14, 20"/>
@jfversluis
jfversluis / Grid.xaml
Created Jun 4, 2020
Example of a Xamarin.Forms Grid definition
View Grid.xaml
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="300" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
@jfversluis
jfversluis / MainPageViewModel.cs
Last active Mar 30, 2020
View model for our main page
View MainPageViewModel.cs
using System.Collections.ObjectModel;
using Xamarin.Forms;
namespace DataBindingScopeSample
{
public class ListModel
{
public string Title { get; set; }
public string Image { get; set; }
}