如何使用C#wpf应用程序中的F#类型(How to use F# types from C# wpf application)

编程入门 行业动态 更新时间:2024-10-19 02:21:37
如何使用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.

更多推荐

本文发布于:2023-08-01 20:37:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1363711.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   应用程序   类型   application   wpf

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!