Skip to content

Instantly share code, notes, and snippets.

View jamesmcroft's full-sized avatar
👨‍💻
Coding From Anywhere

James Croft jamesmcroft

👨‍💻
Coding From Anywhere
View GitHub Profile
<Grid AllowDrop="True" DragOver="OnFileDragOver" DragLeave="OnFileDragLeave" Drop="OnFileDrop">
<GridView x:Name="FileList" ItemsSource="{Binding Files}" IsItemClickEnabled="True" SelectionMode="None" />
<RelativePanel x:Name="AddFilePanel" Background="#44000000" Visibility="Collapsed">
<SymbolIcon x:Name="AddSymbol" Symbol="Add" RelativePanel.AlignVerticalCenterWithPanel="True" RelativePanel.AlignHorizontalCenterWithPanel="True" Foreground="White" RenderTransformOrigin="0.5,0.5">
<SymbolIcon.RenderTransform>
<CompositeTransform ScaleX="1.5" ScaleY="1.5"/>
</SymbolIcon.RenderTransform>
</SymbolIcon>
namespace DragDropXAML
{
public class DragDropXAMLExample
{
public ObservableCollection<AppFile> Files { get; }
private void OnFileDragOver(object sender, DragEventArgs e)
{
e.AcceptedOperation = DataPackageOperation.Copy;
@jamesmcroft
jamesmcroft / UIElementParallaxEffectBehavior.cs
Created January 10, 2016 22:04
A simple parallax effect behavior which can be attached to scrolling UI elements
public class UIElementParallaxEffectBehavior : DependencyObject, IBehavior
{
public static readonly DependencyProperty ParallaxElementProperty =
DependencyProperty.Register(
"ParallaxElement",
typeof(UIElement),
typeof(UIElementParallaxEffectBehavior),
new PropertyMetadata(null, OnParallaxElementChanged));
public static readonly DependencyProperty ParallaxMultiplierProperty =
if(ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
{
Windows.Phone.UI.Input.HardwareButtons.BackPressed += this.OnHardwareBackPressed;
}
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += this.OnBackRequested;
...
private void OnBackRequested(object sender, BackRequestedEventArgs e)
{
// Handle frame navigation
}
namespace WinUX.Extensions
{
using System;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Graphics.DirectX;
using Windows.Graphics.Display;
using Windows.Graphics.Imaging;
using Windows.Storage;
<UserControl
x:Name="ControlRoot"
x:Class="WinUX.Xaml.Controls.Inking.DrawingCanvas"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignWidth="500"
d:DesignHeight="200">
@jamesmcroft
jamesmcroft / ValidatingTextBox.xaml
Created May 6, 2016 12:13
Example of how to use the ValidatingTextBox
<Grid>
<Grid.Resources>
<validation:ValidationRules x:Key="UrlSample">
<validation:ValidationRules.Rules>
<rules:UrlValidationRule />
</validation:ValidationRules.Rules>
</validation:ValidationRules>
</Grid.Resources>
<controls:ValidatingTextBox IsMandatory="True" Header="Website" Text="http://www.jamescroft.co.uk" MaxLength="50" ValidationRules="{StaticResource UrlSample}" />
public MainPage()
{
this.InitializeComponent();
this.myCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Pen; // Enables only pen.
this.myCanvas.InkPresenter.InputDeviceTypes = Windows.UI.Core.CoreInputDeviceTypes.Pen | Windows.UI.Core.CoreInputDeviceTypes.Touch; // Enables pen and touch.
}
public MainPage()
{
// Initialization of page and inking inputs...
this.myCanvas.InkPresenter.ActivateCustomDrying();
this.myCanvas.InkPresenter.SetPredefinedConfiguration(InkPresenterPredefinedConfiguration.SimpleMultiplePointer); // This turns on multi pointer input.
}