1

I'm not very familiar with WPF, and I use it with F#. The scenario is that I have a dataset with parentID that I'd like to display in a treeview. (For the little story, the rows are snapshots coming from a scvmm VM)

I have a working code that uses an enumerator of the dataset and populates the treeview, however I'd like to use a XAML binding instead. I found WPF how to bind self-referential dataset to a treeview that deals with the exact same in C#, but it uses partial classes that I'm unable to directly translate into F#.

Is this possible, did I follow the wrong avenue trying to translate the above solution, or am I simply missing knowledge on F#/WPF internals?

Thanks a bunch for any pointer!

Community
  • 1
  • 1
Reza
  • 11
  • 2

1 Answers1

1

Answer

You can use the answer which you provided in the link by binding the Window's ViewModel (DataContext) using XAML. Check this question: How do I set a ViewModel on a window in XAML using DataContext property?

Then implement the view model's properties with F# according to the question you found (How do I set a ViewModel on a window in XAML using DataContext property?) and then you should be to able to do use the XAML binding.

WPF + F# in general

In general using XAML, WPF and F# only is a bad combination because of the lack of partial classes in F#. Usually i write views (WPF/XAML project) with C# and view models with F#.

Community
  • 1
  • 1