Skip to content

Instantly share code, notes, and snippets.

View sjehutch's full-sized avatar

scott hutchinson sjehutch

View GitHub Profile
@sjehutch
sjehutch / IPageService.cs
Created January 14, 2021 16:27
Page Navigation Xamarin Service
using System;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace NewYoutube.Services
{
public interface IPageService
{
Task PushAsync(Page page);
Task PushModalAsync(Page page);
@sjehutch
sjehutch / Test.xaml
Last active August 24, 2020 11:31
Property For MVVM Trigger
<Label Text="{Binding LocationLine}" FontSize="Small">
<Label.Triggers >
<DataTrigger TargetType="Label" Binding="{Binding LocationLine}" Value="NA">
<Setter Property="TextColor" Value="Gray"/>
</DataTrigger>
</Label.Triggers>
</Label>
<Label Text="{Binding ContainerLine}" FontSize="Small">
<Label.Triggers>
<DataTrigger TargetType="Label" Binding="{Binding ContainerLine}" Value="NA">
@sjehutch
sjehutch / Getter.cs
Created August 2, 2020 13:38
Basic Getter Setter Xamarin
private string _fullname;
public string FullName
{
protected set
{
if (_fullname != value)
{
_fullname = value;
OnPropertyChanged("FullName");
}
@sjehutch
sjehutch / LoginPage.xaml
Created August 1, 2020 15:42
Login.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:local="clr-namespace:mainn"
xmlns:accordion="clr-namespace:Syncfusion.XForms.Accordion;assembly=Syncfusion.Expander.XForms"
x:Class="mainn.MainPage"
xmlns:vm="clr-namespace:mainn.ViewModels">
<ContentPage.Resources>
<ResourceDictionary>
<vm:MainViewModel x:Key="vm"/>
</ResourceDictionary>
</ContentPage.Resources>
@sjehutch
sjehutch / NavHelper.cs
Created July 28, 2020 03:33
NavHelper MVVM Xamarin
public static class NavHelper
{
public static Page CurrentPage => Application.Current.MainPage;
private static INavigation Navigation => CurrentPage.Navigation;
public static async Task PopAsync()
{
var masterDetailPage = CurrentPage as MasterDetailPage;
@sjehutch
sjehutch / MainView.xaml
Last active July 27, 2020 08:39
Binding to viewmodel
<?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:local="clr-namespace:mainn" xmlns:accordion="clr-namespace:Syncfusion.XForms.Accordion;assembly=Syncfusion.Expander.XForms"
x:Class="mainn.MainPage"
xmlns:vm="clr-namespace:mainn.ViewModels">
<ContentPage.Resources>
<ResourceDictionary>
<vm:MainViewModel x:Key="vm"/>
</ResourceDictionary>
</ContentPage.Resources>
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Xamarin.Forms;
namespace EntryCompleteEvent
{
public class MyViewModel : INotifyPropertyChanged
{
public MyViewModel()
{
@sjehutch
sjehutch / EventCompleteBehavior
Created June 30, 2020 13:29
Xamarin Entry Complete Event
using System;
using System.Reflection;
using System.Windows.Input;
using Xamarin.Forms;
namespace EntryCompleteEvent
{
public class EntryCompletedBehavior : Behavior<Entry>
{
protected override void OnAttachedTo(Entry bindable)
// Retrieve installation from local storage and
// create new one if it does not exist
var installation = SettingsHelper.Installation;
if (installation == null)
{
installation = new Installation
{
InstallationId = Guid.NewGuid().ToString(),
Platform = NotificationPlatform.Wns,
PushChannel = pushNotificationChannel.ToString(),
@sjehutch
sjehutch / MapNums.cs
Created August 18, 2019 14:04
Hackrank for loop
using System;
namespace myBlank
{
class Program
{
private static object a;
static void Main(String[] args)