DesignInstance not working in VS2012

后端 未结 4 1830
面向向阳花
面向向阳花 2021-01-01 18:40

I just spent several hours on an issue when using VS2012, WPF 4.5 and design-time data, specifically the DesignInstance attribute.

Goal: I wanted to

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-01 19:08

    Check if the "Platform target" in your build configuration is set to "AnyCPU". My was set to "x64", so the designer was complaining about the missing type.

    VS is running in 32 bit so maybe there is an issue with executing code from 64 bit assemblies.

    I found the solution when trying to open my UserControl in "Blend for Visual Studio". It displayed an neat exception to me.

    P.S.: After using the accepted answer: Use "d:Type=vm:DesignAlertsViewModel" instead of "vm:DesignAlertsViewModel" my control was visible, but no example data was displayed.

提交回复
热议问题