2

I have added Report.rpt and a Report.fs file by right clicking on project in Solution Explorer. In Report.fs I have declared two Type Report() and CachedReport(), which in C# are generated automatically, and added F# code in it by looking at a .cs file which CrystalReport generated in a C# WPF Projet. In Xaml I have

<ContentControl Content="{Binding ShowReport}"/>
<Button Command="{Binding ViewReport}" Content="Click" Grid.Row="1"/>

and in ViewModel

let doc = new CrystalReportsViewer()
let setSource() = 
    let rpt = new Report()
    rpt.Load("~/Report.rpt")
    doc.ViewerCore.ReportSource <- rpt
member x.ShowReport =  doc
member x.ViewReport = self.Factory.CommandSync(setSource)

When I start the application I can see CrystalReport Viewer in place. If I click the button Application closes automatically.

If I double click on Report.rpt a dialog box pops up and says This document could not be opened.

How can I use it in F# WPF? Is there any other reporting tool for F# WPF?

1 Answers1

0

I just need to build a C# Class Library with a Report as embedded resource, add the assembly in F# reference and write ...

let doc = new CrystalReportsViewer()
let setSource() = 
    let rpt = new MyCsClass.CrystalReport1()
    ....
    doc.ViewerCore.ReportSource <- rpt 

thats all!