none
Referencing WPF namespaces in F# 4.0 RRS feed

  • Question

  • I am going through several resources to learn F#, including the Pluralsight course, Introduction to F#. I am using VS2015 Enterprise. The code I'm using is:

    open System

    open System.Windows

    open System.Windows.Controls

    let loadWindows() = 

        letresourceLocator = newUri("/HelloWorldWPF;component/MainWindow.xaml", UriKind.Relative)

        letwindow = Application.LoadComponent(resourceLocator) :?> Window

        (window.FindName("clickButton") :?> Button).Click.Add(

            fun_ ->MessageBox.Show("Hello World!") |> ignore)

        window

    [<STAThread>]

    (newApplication()).Run(loadWindow()) |> ignore

    I've got a simple XAML page as a resource:

    <Windowxmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MainWindow"Height="300"Width="500">

        <Grid>

            <ButtonName="clickButton"Content="Click me!"Height="40"Width="150" />

        </Grid>

    </Window>

    I'm getting errors that Application, Window and Grid are not defined.  It seems there is a namespace reference issue.  I could only get the "open System.Windows.Controls" to avoid an error after adding a reference to the System.Windows.Controls.Ribbon assembly.

    My question is,  "How does one reliably set .NET namespace references in F#?

          

     


       


           


       

           

       

    Saturday, April 16, 2016 4:13 PM

Answers

All replies