Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use F# types from C# wpf application

Tags:

c#

wpf

f#

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.

like image 556
RomanKovalev Avatar asked Feb 19 '23 13:02

RomanKovalev


1 Answers

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.

like image 195
Clemens Avatar answered Feb 21 '23 02:02

Clemens