简体   繁体   中英

How to use F# types from C# wpf application

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM