Skip to content

Instantly share code, notes, and snippets.

View dansiegel's full-sized avatar
:octocat:
Slinging Code

Dan Siegel dansiegel

:octocat:
Slinging Code
View GitHub Profile
@dansiegel
dansiegel / BehaviorBase{T}.cs
Created August 3, 2016 22:03
Prism Tabbed Navigation
public class BehaviorBase<T> : Behavior<T> where T : BindableObject
{
public T AssociatedObject { get; private set; }
protected override void OnAttachedTo( T bindable )
{
base.OnAttachedTo( bindable );
AssociatedObject = bindable;
if( bindable.BindingContext != null )
@dansiegel
dansiegel / PrismNavigationPage.xaml
Created August 24, 2016 19:23
Prism NavigationPage
<?xml version="1.0" encoding="utf-8" ?>
<NavigationPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
BackgroundColor="{Binding BackgroundColor}"
BarBackgroundColor="{Binding BarBackgroundColor}"
BarTextColor="{Binding BarTextColor}"
Title="{Binding Title}"
x:Class="MyProject.Views.PrismNavigationPage">
</NavigationPage>
@dansiegel
dansiegel / README.md
Last active June 29, 2018 21:40
MVVM Loading ViewModel for Design Time

Overview

The purpose of this Gist is to help provide a workaround to load a ViewModel into a Xamarin Forms View following a MVVM pattern that dynamically loads the ViewModel such as Prism. This example will be based on the use of such a project.

Getting Started

To Start Create a Build Profile in your Solution and any project containing your Views that you can use for Design Time. The name doesn't really matter, but for the purposes of this example we'll simply call it Design. You may need to do some tweaking, but the most critical is that your project containing your Views and ViewModel's should be mapped to use the Design Build Profile when using the Solution's Build Profile. The Unit Tests do not have to be built in this profile but they can depending on your needs.

Next edit the build properties for the solution containing those Views and ViewModels. You will want to define a new Compiler constant. If you copied the Debug profile you should see constants already defined like DEBUG;TRACE;.

@dansiegel
dansiegel / App.xaml.cs
Created April 18, 2017 20:05
Prism Debug
public partial class App : PrismApplication
{
public App(IPlatformInitializer initializer = null) : base(initializer)
{
}
protected override void OnInitialized()
{
try
{
@dansiegel
dansiegel / App.xaml.cs
Last active July 31, 2017 01:46
Basic Prism Logging
namespace AwesomeApp
{
public partial App : PrismApplication
{
protected override ILoggerFacade CreateLogger() =>
new AwesomeApp.Services.DebugLogger();
}
}
@dansiegel
dansiegel / .gitignore
Created April 24, 2018 18:10
Mobile BuildTools Secrets
secrets.json
@dansiegel
dansiegel / _colors.scss
Created April 26, 2018 16:11
Sass for Xamarin Forms.
$primaryColor: #303F9F;
@dansiegel
dansiegel / Info.plist
Created April 26, 2018 16:47
Tokenized Manifest
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>appcenter-$$APP_SECRET$$</string>
</array>
</dict>
</array>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{9F0236FA-9A36-40CB-924F-4CA379E05CE1}</ProjectGuid>
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
@dansiegel
dansiegel / INavigationServiceExtensions.cs
Created May 30, 2018 19:59
Prism Tabbed Navigation
using System;
using System.Linq;
using System.Threading.Tasks;
using Prism.Common;
using Xamarin.Forms;
namespace Prism.Navigation
{
public static class INavigationServiceExtensions
{