Skip to content

Instantly share code, notes, and snippets.

@LosManos
Last active August 29, 2015 14:18
Show Gist options
  • Save LosManos/189b3adba9401272b088 to your computer and use it in GitHub Desktop.
Save LosManos/189b3adba9401272b088 to your computer and use it in GitHub Desktop.
XAML stuff
public ViewModel VM { get; set; } // View model.
public MainWindow()
{
VM = new ViewModel();
InitializeComponent();
PreviewKeyDown += HandleEsc; // Esc to close window.
}
// Esc to close window.
private void HandleEsc(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
Close();
}
}
/*
<Window x:Class="WhatIsInTheBarnBooth.MainWindow"
x:Name="MyWindow" <- Set for View model.
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
DataContext="{Binding ElementName=MyWindow, Path=VM}"> <- Set View model.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment