UserControl包含我的自定义控件时出现ExpressionBlend异常 [英] ExpressionBlend exception when UserControl contains my custom control

查看:61
本文介绍了UserControl包含我的自定义控件时出现ExpressionBlend异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在Visual Studio中很好地编辑此UserControl,但在表达式混合中却遇到了这个奇怪的异常.有人知道我应该找什么吗?

I can edit this UserControl just fine in visual studio but I get this strange exception in expression blend. Does anybody know what should I look for?

更新

我无法弄清楚如何调试/附加.我按照Mike的指示进行了所有操作,但没有遇到断点.我进行了更多调查,发现我的问题很可能与themes/generic.xaml

I wasn't able to figure how to debug/attach. I did everything as instructed by Mike but no breakpoints got hit. I did more investigation and found that most likely my issue related to themes/generic.xaml

我的Visual Studio解决方案有一个名为Infrastructure.dll的项目.在该项目中,我有文件夹themes,在文件中有generic.xaml. Generic.xaml设置为作为资源编译.我的控制班住在同一个项目中.

My visual studio solution has project named Infrastructure.dll. Inside that project I have folder themes and inside I have file generic.xaml. Generic.xaml set to compile as resource. My control class lives in a same project.

我还有一个名为"Module.dll"的项目,该项目引用了Infrastructure.dll

I have another project named 'Module.dll' and that project references Infrastructure.dll

  1. 当我使用控件打开视图(视图来自Infrastructure.dll)时,它可以在Visual Studio中运行,但在Blend中会出现此错误.
  2. 我可以在Blend中拖放控件,并且会给出相同的错误.我试图删除将模板应用于控件的行(generic.xaml中的模板),并且该行有效.
  3. 模板很好,我使用Blend创建了模板,然后自己复制到了generic.xaml.
  4. 当我创建视图INSIDE Infrastructure.dll并将控件放到该视图上时,它会起作用.

所以,我的结论是,Blend没有看到generic.xaml中存在于引用项目中的模板.我该如何解决?

So, my conclusion is that Blend doesn't see template inside generic.xaml that lives in referenced project. How do I fix this?

推荐答案

问题肯定与Blend无法读取/定位generic.xaml有关 视觉工作室没有这个问题顺便说一句.我现在发现了解决方法-如果我可以避免这样做,将很乐意接受另一个答案.

Issue was definitely related to Blend's inability to read/locate generic.xaml Visual studio doesn't have this issue btw. I found workaround for now - will gladly accept another answer if I can avoid doing that..

在添加资源引用以进行查看之后-一切都在Blend中工作.这意味着我必须将此XAML添加到我的所有视图中.

After I add resource reference to view - everything works in Blend. This means I have to add this XAML to all my views..

<UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Infrastructure.SL;component/Themes/generic.xaml"/>
            </ResourceDictionary.MergedDictionaries> 

这篇关于UserControl包含我的自定义控件时出现ExpressionBlend异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆