我试图在MainWindow
添加使用FSharp.Charting
折线图。在MainViewModel我有 -添加WindowsFormsHost抛出XamlParseException
let chart = Chart.Line [ for i in 0 .. 10 -> (i, i * i) ]
let control = new ChartControl(chart)
member self.LineChart = control
,并在XAML -
<WindowsFormsHost Child="{Binding LineChart}" />
当我启动应用程序,我得到XamlParseException
具有以下附加信息 -
'Cannot create unknown type '{http://schemas.microsoft.com/winfx/2006/xaml/presentation}WindowsFormsHost'.' Line number '20' and line position '10'.
如何解决这个问题?
这是@Foggy Finder。我已经删除了定义TextBlock和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>
为什么不使用'OxyPlot'或“LiveCharts”? –
你可以显示完整的XAML(或至少它的标题)吗? –
'FSharpCharting'似乎比'LiveChart'更容易。我还不熟悉OxyPlot' @FoggyFinder –