Funk
Funk

Reputation: 11201

Interface Object syntax in F#

I'm translating C# code for multipage printing into F# . Could somebody tell me how to translate:

((IAddChild)page1Content).AddChild(page1)

context:

       // printdia = printdialog
       // printdoc = printdocument

       // create a page
       let page1 = new System.Windows.Documents.FixedPage()
       page1.Width <- printdoc.DocumentPaginator.PageSize.Width
       page1.Height <- printdoc.DocumentPaginator.PageSize.Height
       page1.Children.Add(printcanvas) |> ignore
       // add the page to the document
       let page1Content = new System.Windows.Documents.PageContent()
 (*C#*)((IAddChild)page1Content).AddChild(page1)
       printdoc.Pages.Add(page1Content) |> ignore
       // and print
       printdia.PrintDocument(printdoc.DocumentPaginator, ordernr.Text);

Original code in C#

Upvotes: 3

Views: 72

Answers (1)

Daniel Fabian
Daniel Fabian

Reputation: 3838

If page1Content.AddChild(page1) does not work, try (page1Content :> IAddChild).AddChild(page1).

Upvotes: 5

Related Questions