Search code examples
f#record

Strange behaviour of F# record with FlowDocument


I tried to create an F# record type containing a FlowDocument in Visual Studio 2012 RC somewhat like this:

module RecordTest =
    open System.Windows.Documents

    type TestRecord =
        {
            TestName : FlowDocument
        }

    let test = { TestName = new FlowDocument () }

The strange thing is, this does not work for me. Visual Studio tells me: The record label TestName is not defined. and hovering over the type definition of TestRecord does not reveal a tool tip. If I change the type of TestName to e.g. string, everything works as it should.

For FlowDocument, a reference to PresentationFramework.dll is needed.

What's going on here? Anybody able to get this working?

Thanks.

Future readers: if something seems unclear or inconsistent with the question, answer ans comments, please note that the original question (to which the answer and some of the comments refer) had different indentation (which affects the code). I am not rolling back the edit, because some of the comments do refer to the indented version. -- July 31st, Ramon Snir


Solution

  • I got this to work by indenting everything after the first line (NB this has now been done in the code sample in the question), and adding references to PresentationCore, System.Xaml and WindowsBase as well as PresentationFramework.

    Not sure this explains your error message, however!

    I'm using VS2010 so the behaviour may be different.