如何使用C#wpf应用程序中的F#类型(How to use F# types from C# wpf application)
在F#中,我的代码结构如下:
module MyNS.MyModule type SomeType = member x.value = "some value"与它组装名为MyNs代码。 我从C#WPF应用程序引用它并在XAML中执行相同的操作:
<UserControl x:Class="WpfTest" xmlns:data="clr-namespace:MyNS;assembly=MyNs">然后我尝试在DataTemplate使用SomeType :
<DataTemplate DataType="{x:Type data:MyModule.SomeType}">但是有关于缺少类型的错误。
In F# I have code with structure like this:
module MyNS.MyModule type SomeType = member x.value = "some value"Assemble with it code named MyNs. I referenced to it from C# WPF application and do the same in XAML:
<UserControl x:Class="WpfTest" xmlns:data="clr-namespace:MyNS;assembly=MyNs">then I trying to used SomeType in DataTemplate:
<DataTemplate DataType="{x:Type data:MyModule.SomeType}">But have an error about missing type.
最满意答案
我认为它应该如下所示, MyModule+SomeType而不是MyModule.SomeType用于嵌套类。
<UserControl x:Class="WpfTest" xmlns:data="clr-namespace:MyNS;assembly=MyNs"> <DataTemplate DataType="{x:Type data:MyModule+SomeType}">在SO上找到它。
I think it should look like below, with MyModule+SomeType instead of MyModule.SomeType for a nested class.
<UserControl x:Class="WpfTest" xmlns:data="clr-namespace:MyNS;assembly=MyNs"> <DataTemplate DataType="{x:Type data:MyModule+SomeType}">Found it here on SO.
更多推荐
发布评论