I was trying to add a Line Chart using FSharp.Charting
in MainWindow
. In MainViewModel I have -
let chart = Chart.Line [ for i in 0 .. 10 -> (i, i * i) ]
let control = new ChartControl(chart)
member self.LineChart = control
and in xaml -
<WindowsFormsHost Child="{Binding LineChart}" />
When I start the application, I get XamlParseException
with following additional information -
'Cannot create unknown type '{http://schemas.microsoft.com/winfx/2006/xaml/presentation}WindowsFormsHost'.' Line number '20' and line position '10'.
How to solve the problem?
Here it is @Foggy Finder. I have removed few lines defining TextBlock and Buttons.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ViewModels;assembly=AsyncFS"
xmlns:fsxaml="http://github.com/fsprojects/FsXaml"
Title="MVVM and XAML Type provider" Height="200" Width="400">
<Window.DataContext>
<local:MainViewModel/>
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<WindowsFormsHost Child="{Binding LineChart}" />
</Grid>
In order to use
WinfowsFormsHost
you need to add a reference toWindowsFormsIntegration
. But if you do it you get :Easy way to fix is to create the object directly:
...
Result: