引用F#ViewModel的C#WPF项目 [英] C# WPF project with reference to F# ViewModel
本文介绍了引用F#ViewModel的C#WPF项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个名为FSharpProject的项目中有这样的代码:
I have project named FSharpProject in whick there is code like this:
module FSharpProject.ViewModel
type A =
member x.a = 1
在其他引用了FSharpProject的项目(典型的WPF应用程序,用C#语言编写)中,我有xaml文件,如下所示:
In other project(typical wpf application writing in C#) which have reference to FSharpProject I have xaml file like this:
<UserControl x:Class="CSharpProjectView"
x:Name="Root"
xmlns:local="clr-namespace:CSharpProjectView"
xmlns:data="clr-namespace:FSharpProject.ViewModel;assembly=FSharpProject"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
...
<DataTemplate x:Key="LogDataTemplate" DataType="{data:A}">
<TextBlock Text="{Binding a}" />
</DataTemplate>
但是我发现data:A类型找不到错误.
But I get error that data:A type not found.
UPD:它不起作用:
UPD: It does not work:
<UserControl x:Class="CSharpProjectView"
x:Name="Root"
xmlns:local="clr-namespace:CSharpProjectView"
xmlns:data="clr-namespace:FSharpProject;assembly=FSharpProject"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
...
<DataTemplate x:Key="LogDataTemplate" DataType="{data:ViewModel.A}">
<TextBlock Text="{Binding a}" />
</DataTemplate>
推荐答案
您的DataType
应该只是data:A
或{x:Type data:A}
:
<DataTemplate x:Key="LogDataTemplate" DataType="data:A">
这篇关于引用F#ViewModel的C#WPF项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文