[英]C# WPF project with reference to F# ViewModel
I have project named FSharpProject in whick there is code like this: 我在一个名为FSharpProject的项目中有这样的代码:
module FSharpProject.ViewModel
type A =
member x.a = 1
In other project(typical wpf application writing in C#) which have reference to FSharpProject I have xaml file like this: 在其他引用FSharpProject的项目(典型的WPF应用程序,用C#编写)中,我有xaml文件,如下所示:
<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>
But I get error that data:A type not found. 但我收到以下错误数据:找不到类型。
UPD: It does not work: UPD:它不起作用:
<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">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.