Skip to content

Instantly share code, notes, and snippets.

@schuster-rainer
Created October 1, 2011 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schuster-rainer/1256598 to your computer and use it in GitHub Desktop.
Save schuster-rainer/1256598 to your computer and use it in GitHub Desktop.
prototyping panel with fsi and WPF
#if INTERACTIVE
#load "load-wpf.fsx"
#endif
// === WPF ===
open System.Windows
open System.Windows.Controls
open System.Windows.Media.Imaging
// Create Window and StackPanel
let window = new Window(Title = "Prototyping")
window.Show()
let scroll = new ScrollViewer()
let panel = new WrapPanel()
panel.Orientation <- Orientation.Horizontal
panel.ItemWidth <- 350.0
panel.HorizontalAlignment = HorizontalAlignment.Left;
panel.VerticalAlignment = VerticalAlignment.Top;
scroll.Content <- panel
window.Content <- scroll
let stack content =
panel.Children.Add content
let stackImage (img:System.Drawing.Image) =
let bi = new BitmapImage()
bi.BeginInit()
let ms = new MemoryStream()
img.Save (ms, ImageFormat.Bmp)
let offset = ms.Seek (0L, SeekOrigin.Begin)
bi.StreamSource <- ms
bi.EndInit()
bi.Freeze()
let imageControl = new Image()
imageControl.Source <- bi
stack imageControl
// === WPF ===
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment