I have an F# WPF application with view model classes. These classes need to be public in order to be used in the XAML as data types.
The problem is that it appears that when using F# type recursion (and) then the subordinate types are not accessible - or they appear not to be. That is to say that given this example:
type Foo () =
member this.Bar = new Bar()
and Bar () =
member this.Foo = new Foo()
then Bar is not accessible in the XAML.
I have tried to prefix Foo with public and Bar also. I've also tried to create a synonym. Neither of those changes solved the problem.
Is this really how it works or am I "doing it wrong"? If it is the way it works, can I then force the subordinate types (Bar, in the example) to be public?
Thanks! :-)
Update 1: On closer inspection (dotPeek) it appears that access is the same. The F# compiler creates a static outer class Foo and a nested class Foo. It does the same with Bar. They are all marked as public. Now I'm perplexed as to why Bar is not accessible from within XAML.
Update 2: Solved. WPF doesn't like discriminated unions. One or more of the subordinate types use discriminated unions and that prevents it from being used for XAML databinding.
WPF doesn't like discriminated unions. One or more of the subordinate types use discriminated unions and that prevents it from being used for XAML databinding. Not quite obvious but that was the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With