Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This file is to be used with this gist: you will be able to use an adaptive trigger depending on the device type, this code is base on @dotMorten code which can be found here:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
namespace Win10.StateTriggers
//you will also need
public class DeviceFamilyStateTrigger : StateTriggerBase
private static DeviceTypeEnum deviceFamily;
static DeviceFamilyStateTrigger()
deviceFamily = DeviceTypeHelper.GetDeviceType();
public DeviceTypeEnum DeviceFamily
get { return (DeviceTypeEnum)GetValue(DeviceFamilyProperty); }
set { SetValue(DeviceFamilyProperty, value); }
public static readonly DependencyProperty DeviceFamilyProperty =
DependencyProperty.Register("DeviceFamily", typeof(DeviceTypeEnum), typeof(DeviceFamilyStateTrigger),
new PropertyMetadata(DeviceTypeEnum.Other, OnDeviceTypePropertyChanged));
private static void OnDeviceTypePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
var obj = (DeviceFamilyStateTrigger)d;
var val = (DeviceTypeEnum)e.NewValue;
if (deviceFamily == val)
obj.IsActive = true;
private bool m_IsActive;
public bool IsActive
get { return m_IsActive; }
private set
if (m_IsActive != value)
m_IsActive = value;
if (IsActiveChanged != null)
IsActiveChanged(this, EventArgs.Empty);
public event EventHandler IsActiveChanged;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment