BindingError during binding to viewmodel interface implementation via F #

Hi guys, sorry for such a long question, but ...

I have a C # interface, like this one:

public interface ISimpleViewModel
{
    string SimpleText { get; }
}

Then I have the type F # inherited from it:

type SimpleViewModel() = 
    interface ISimpleViewModel with
        member this.SimpleText
            with get() = "Hello again!"

I also have a C # descendant:

public class SimpleCSViewModel : ISimpleViewModel
{
    public string SimpleText
    {
        get { return "Just testing"; }
    }
}

In the end, I have a super simple WPF application that MainWindow ctor is injected with an ISimpleViewModel instance like this:

public partial class MainWindow : Window
{
    public MainWindow(ISimpleViewModel viewModel)
    {
        ViewModel = viewModel;
        InitializeComponent();
    }

    public ISimpleViewModel ViewModel
    {
        get { return DataContext as ISimpleViewModel; }
        set { DataContext = value; }
    }
}

And, of course, I have a TextBlock in my window whose Text property is bound to a SimpleText.

Everyting works when I insert a C # instance. But I get a BindingError that the property can be found in the case of an F # instance. Why could this be so?

+3
source share
1 answer

, WPF, , F # ( , ), ' #. , #? , F #, .

+3

All Articles