coroutine (2) form (1) HTML (5) layout (1) MVVM (2) Observable (5) prettyprint (1) window (1) windows forms (2) winforms (6) WPF (15) XAML (2)

Snippets in category User Interface

  • Form changing color

    Windows Forms tutorial showing how to create form with button and how to register an event handler. When the button is clicked, the form changes its background color.

    29 people like this
    Posted: 1 years ago by Tomas Petricek

  • Load XAML

    This example shows how to load a Xaml file allowing to use WPF from F#. It also shows how to access WPF objects and register event handlers.

    59 people like this
    Posted: 1 years ago by Antonio Cisternino

  • FSX Structure

    I use this basic template when writing .fsx files that I might want to compile. It adjusts the difference in command line/entrypoint handling between a script and a compiled assembly. This example shows the details for a WPF script — replace the #r's and/or remove the STAThread for a WinForms or Console script.

    66 people like this
    Posted: 1 years ago by Blake Coverett

  • WinForms layout combinators

    A domain specific language for creating layout using Windows Forms. The snippet implements combinators for creating controls and simple automatic arrangement of them.

    17 people like this
    Posted: 1 years ago by Tomas Petricek

  • debugging window

    The window is useful when you want to print out data to the screen.

    9 people like this
    Posted: 1 years ago by Stefan Knoblauch

  • ObservableObject

    The ObservableObject type implements the INotifyPropertyChanged interface used in WPF and Silverlight to notify on changes to properties that are bound to a control. Specify property names type safely using F# Quotations, i.e. <@ this.PropertyName @> when invoking the NotifyPropertyChanged method. If you are following the MVVM pattern then your View Model class can inherit from the ObservableObject type.

    45 people like this
    Posted: 1 years ago by Phillip Trelford

  • Observable.Subject

    The Subject<T> type implements both IObserver<T> and IObservable<T>. It is functionally equivalent to the type of the same name in the Reactive Extensions (Rx) library.

    13 people like this
    Posted: 1 years ago by Phillip Trelford

  • WPF Custom Control

    This snippet shows how to create a WPF custom control library in F#.

    30 people like this
    Posted: 1 years ago by Fahad

  • WPF DepdencyProperty

    Declaring WPF DependencyProperty in F#

    16 people like this
    Posted: 1 years ago by Fahad

  • Chronological sequence window beginnings

    An abstraction of the following use case: Given a sequence of dates and max temperatures for each date, extract out the initial dates on which the temp is greater than a given threshold for n consecutive days. (Originally posted as an answer to this StackOverflow question: http://stackoverflow.com/questions/5267055 )

    10 people like this
    Posted: 1 years ago by ildjarn

  • Pretty Print Source Code Errors

    A snippet that allows you to pretty print source code errors

    13 people like this
    Posted: 1 years ago by fholm

  • Web Crawler

    This snippet features an F# Web crawler that i'm already using in 2 applications (slightly modified). It's based on a scalable network of communicating agents that follow URLs extracted from HTML pages until reaching the specified limit.

    20 people like this
    Posted: 1 years ago by Taha Hachana

  • F# Quotations with INotifyPropertyChanged

    ViewModelBase for F# users who want to use it in WPF / Silverlight

    6 people like this
    Posted: 1 years ago by Fahad

  • WebSharper Hello World

    This sample implements "Hello, world!" as a WebSharper application. It demonstrates how to compose HTML/XML using combinators, how to dynamically create a button with a handler and how to update an existing DOM element.

    2 people like this
    Posted: 12 months ago by Tomas Petricek

  • Structural BeginUpdate / EndUpdate with Lambda

    Several WinForms controls, like TreeView and ListView, implement methods BeginUpdate and EndUpdate, which suspend repainting of the control while items are being individually added to a control, preventing flicker caused by rapid repainting. But using BeginUpdate and EndUpdate is very imperative, and opens up the possibility for bugs, such as neglecting to call the matching EndUpdate. An obvious improvement would be to create an extension method on types implementing this pattern which takes a unit -> unit lambda which is executed between update pairs. But the pattern is only conventional, rather than through a common base class or interface. Hence this presents a reasonable opportunity to use F#'s statically resolved structural type system to implement a function which only works on Control types with the correct structural signature.

    2 people like this
    Posted: 12 months ago by Stephen Swensen

  • A fun-ny WPF DataTemplate DSL

    Parts of a little DSL to create WPF DataTemplate's in F#. Don't even want to think about the length of a corresponding C#. The F# code corresponds 1-to-1 to the visual tree constructed for the template.

    5 people like this
    Posted: 11 months ago by Cetin Sert

  • Simple F# ViewModel for Silverlight MVVM

    Silverlight default architecture is Model-View-ViewModel. This code gives full design time support for Microsoft Expression Blend. The F# ViewModel is seen as strongly typed data source in the Blend UI. There are two properties binded to the view: HiLabel (OneWay data binding) and MyName (TwoWay data binding). ViewModel implements the INotifyPropertyChanged to support the binding. The view project (HelloApp) is made with Blend (by designers) and it is Silverlight 5.0 project. The view codebehind is c# file and it has only this.DataContext -assignment. The viewmodel project (HelloApp.ViewModel) is F# Silverlight 4.0 library. It is made with VS2010 and F# (by developers). It contains the logical functionality of the current view.

    4 people like this
    Posted: 11 months ago by Tuomas Hietanen

  • ReplaySubject

    The ReplaySubject<T> type implements both IObserver<T> and IObservable<T>. It is functionally equivalent to the class of the same name in the Reactive Extensions (Rx) library with a replay buffer of a specified size .

    1 people like this
    Posted: 11 months ago by Phillip Trelford

  • RichTextBox SQL highlighting

    Simple RichTextBox SQL highlighting with win32 LockWindowUpdate DllImport

    7 people like this
    Posted: 11 months ago by nCdy

  • WPF/Silverlight Value Converter

    Example of a WPF/Silverlight Value Converter base class and concrete implementation.

    5 people like this
    Posted: 10 months ago by Tao Liu and Daniel Mohl

  • WPF/Silverlight Attached Property

    Example of a WPF/Silverlight Attached Property (AP). This is a port of a C# AP implementation that can be found at http://www.silverlightshow.net/items/Attached-Properties-in-Silverlight.aspx.

    2 people like this
    Posted: 10 months ago by Daniel Mohl

  • WPF Event to Command

    This snippet provides an example of a WPF Event to Command behavior.

    3 people like this
    Posted: 10 months ago by Daniel Mohl

  • Basic WinForms drag and drop

    Quick example of using drag-n-drop with WinForms.

    3 people like this
    Posted: 9 months ago by MichaelGG

  • 12 - Function Display

    Complex function display with two Argand planes, and dots. Added exponential function.

    0 people like this
    Posted: 9 months ago by

  • Coroutine

    An implementation of Coroutine by using a continuation monad. it's using a monad library [1]. [1] https://github.com/fsharp/fsharpx

    3 people like this
    Posted: 8 months ago by einblicker

  • WPF / SilverLight Converter II

    version 1 is http://fssnip.net/62. This new version support convert from any existing function to a converter function by using composition and pipeline. The convert function is to make the function signature agree to the IValueConverter interface. You can add new functions in the FunctionLibrary module and reuse the class definition to reduce the coding effort. The first sample is to show how to make the converter pipeline work, the second one is a debugger converter used to debug the data binding problem.

    74 people like this
    Posted: 8 months ago by Tao Liu

  • Creating observable using Async.StartDisposable

    Implements a simple Async.StartDisposable extension that can be used to easily create IObservable values from F# asynchronous workflows. The method starts an asynchronous workflow and returns IDisposable that cancels the workflow when disposed.

    4 people like this
    Posted: 8 months ago by Tomas Petricek

  • Sliding window for Observable

    Implements the Observable.windowed function that creates an observable returning a sliding window. The function is an observable version of Seq.observable. The implementation uses a simple F# agent that keeps partial windows and sends them to an observer.

    3 people like this
    Posted: 8 months ago by Tomas Petricek

  • Semi-Coroutine

    This snippet implements a semi-coroutine by continuations.

    2 people like this
    Posted: 6 months ago by einblicker

  • Building a WPF application in functional way

    I started to write pure F# + WPF application in about half a year ago. Today, I found a good way to compose WPF controls with dependent values. It's only writing a dependency object type as a class and give it to constructors of GUI controls. In this snippet "Volume","ColorVolume" and "ShapeContainer" has no properties. But works as a View which represents internal Model and allows users to change internal data. You only need calling a constructor of them. It means that you can compose GUI controls and it's functionality as a immutable data structure. (Update 2011/12/02 8:33:00(UTC+09:00) : Removed some user defined operators and renamed a type similar to DependencyObject in this snippet Reactor to SharedValue.) (Update 2011/12/02 9:04:01(UTC+09:00) : renamed some variables..)

    6 people like this
    Posted: 5 months ago by nagat01

  • Union Editor for WinForms PropertyGrid

    A quick-and-dirty editor for discriminated unions in a property grid. I use this for editing trees of F# records and unions. Note that any records must have a "Default" static property which returns a default instance.

    3 people like this
    Posted: 5 months ago by Rick Minerich

  • Observable Async Subject

    Simple Async Observable Subject<'T> based on MailboxProcessor. Type declaration is more ML like, but the idea is represented in a simple way!

    4 people like this
    Posted: 5 months ago by Fahad

  • Drag move for GUI controls

    This script opens a window with a red rectangle which is moved by dragging. I like writing interactive GUI without MVVM, FRP and Markup language.

    3 people like this
    Posted: 4 months ago by nagat01

  • Send HTTP POST request

    The snippet shows how to send HTTP POST request to a web page and download the generated HTML result. The POST data is encoded as a byte array and written to the request stream of HttpWebRequest.

    2 people like this
    Posted: 3 months ago by Tomas Petricek

  • Auto-completion in any winforms text box

    The standard windows.forms text box supports auto-completion, but only for single-line text boxes. The code below can be used to add auto-completion against a fixed set of words to any text box that inherits from TextBoxBase.

    3 people like this
    Posted: 3 months ago by Johann Deneux

  • WPF Command in F#

    demonstrate how to use object expression to create a WPF/Silverlight command.

    17 people like this
    Posted: 2 months ago by Tao Liu

  • Sierpinski triangle, WPF

    Draws a Sierpinski triangle using WPF

    8 people like this
    Posted: 2 months ago by Mathias Brandewinder

  • HTML File Type

    Discriminated unions to represent a HTML file.(not completely)

    2 people like this
    Posted: 1 months ago by Gab_km

  • Speech Stackoverflow article automatically

    This snippet automatically speeches text of question,answers and comments in a Stackoverflow article. It requires HtmlAgilityPack(available from Nuget package manager).(Attention: You need reset F# interactive to stop the speech)

    5 people like this
    Posted: 7 days ago by nagat01