Coder Social home page Coder Social logo

Comments (4)

ReedCopsey avatar ReedCopsey commented on September 26, 2024

I'm fairly certain this is a regression in Visual Studio's XAML editor itself, not related to FSharp.ViewModule. I've seen this (and some other oddities), but have no idea why that'd even be possible as an error message.

DataContext is typed as System.Object, so anything should be a valid DataContext.

from fsharp.viewmodule.

allykzam avatar allykzam commented on September 26, 2024

I had assumed the same when I wrote this up. Don't suppose you know a place I could report this to the VS people without it being ignored or wontfix'd?

from fsharp.viewmodule.

ReedCopsey avatar ReedCopsey commented on September 26, 2024

Closing because it's out of my hands - hopefully VS will fix.

from fsharp.viewmodule.

FuNkNaN avatar FuNkNaN commented on September 26, 2024

There's a workaround to avoid the error.

In the xaml.fs file add

type Wrapper() =
    member __.ViewModel = MainViewModel()

Then in the xaml file change

<Window.DataContext>
    <local:MainViewModel/>
</Window.DataContext>

to

<Window.Resources>
    <ResourceDictionary>
        <local:Wrapper x:Key="Wrapper"/>
        <!--
            Other resources
        -->
    </ResourceDictionary>
</Window.Resources>
<Window.DataContext>
    <Binding Source="{StaticResource Wrapper}" Path="ViewModel"/>
</Window.DataContext>

Seems to resolve the issue at design time. Hope it helps.

from fsharp.viewmodule.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.