How can I debug XAML designer issues?

旧时模样 提交于 2019-12-07 09:08:21

问题


I'm developing a UWP app with Visual Studio 2015, and one of the things I want to do use some sample data at design time.

Now, I've added a XAML file, set the build action as DesignDataWithDesignTimeCrateableTypes

My XAML is really straight forward here:

<local:Freead
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MyNamespace.Uwp.Windows.ViewModels" 
    xmlns:ad="clr-namespace:MyNamespace.Classifieds;assembly=LocalAngle.Uwp" 
    ItemName="Java books" 
    Description="Free to anyone that wants them. A little out of date, but would make a handy doorstop." 
    ContactDetails="01632 960000" 
    Latitude="52.22" Longitude="1.95">
</local:Freead>

However, the intellisense is giving me pale blue wavy line and a tooltip for that of:

Cannot create instance of "Freead".

Historically, I've been able to debug the XAML design issues by firing up another instance of Visual Studio, attaching, and setting to break on all exceptions, but no exceptions appear to be thrown here, so how can I debug why it cannot create an instance of the type? (Given the obvious has already been checked, i.e. there is a parameterless constructor, and solution does build)


回答1:


I was having XAML Designer errors and tried the old pre-Visual Studio 2015 approach:

  • Close any open XAML Designer windows
  • Start another VS 2015 instance up
  • Attach to the "XDesProc.exe" process (for me there was only one)
  • Open the problematic XMAL page in the designer in the original VS instance

My error was "Object not initialized", but it was quite quick to find the underlying problem. Fixing it was a bit more effort!



来源:https://stackoverflow.com/questions/34924922/how-can-i-debug-xaml-designer-issues

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!