Last active
August 29, 2015 14:05
-
-
Save cloudRoutine/caee797434dd478d1884 to your computer and use it in GitHub Desktop.
F# Xaml GUI Quick Reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Xaml Reference | |
module MainApp = | |
// Imports | |
open System | |
open System.Diagnostics | |
open System.Windows | |
open System.Windows.Controls | |
open System.Windows.Markup | |
open System.Xaml | |
open FsXaml // <- Get on nuGet | |
// Type comprisied of the data bindings for MainWindow.xaml's GUI Elements | |
type MainWin = XAML<"MainWindow.xaml"> | |
// Setup elements for access | |
let xamlui = new MainWin () | |
let root = xamlui.CreateRoot () | |
let window = MainWin.Accessor ( root ) | |
// Bindings for GUI Elements | |
let topWin = window.TopWindow | |
let minButton = window.Minimize | |
let maxButton = window.Maximize | |
let closeButton = window.Close | |
// In a borderless/chromeless GUI a background element is necessary to | |
// allow the user to click on any part of the background and move the entire window | |
let backGrip = window.BackGrip | |
// Binds the .DragMove function to mouse event PreviewMouseLeftButtonDown | |
// PreviewMouseLeftButtonDown must be used for the correct functionality | |
backGrip.PreviewMouseLeftButtonDown | |
|> Event.add ( fun e -> root.DragMove() ) | |
//-------------------------------------------------------------------------// | |
// Add to MainWindow.xaml before any elements are declared | |
// someNamespace = Namespace of App.fs's module | |
// someAssembly = Assembly of the project that builds the GUI | |
xmlns:local="clr-namespace:someNamespace;assembly=someAssembly" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment