【问题标题】:Design-time rendering of Silverlight controls in Expression Blend 2Expression Blend 2 中 Silverlight 控件的设计时渲染
【发布时间】:2008-11-18 20:18:34
【问题描述】:

我正在开发一些 Silverlight 控件,我想明确处理它们在 Blend 中的显示方式。 具体来说,这些控件具有在运行时初始化的依赖项,因此会在设计器中引发异常。但即使没有例外,我也想让它们在 Blend 中以某种方式出现。

我知道 WPF 可以做到这一点(使用 myassembly.VisualStudio.Design.dll),但我无法找到有关使用 Silverlight 执行此操作的信息。

我已经看到了here 描述的 hack 来检查这个:

bool designTime = (System.Windows.Browser.HtmlPage.IsEnabled == false);

不过,我更喜欢更明确的解决方案。

【问题讨论】:

    标签: silverlight expression-blend blend expression-blend-2


    【解决方案1】:

    how to deal with design time extensibility here 上有一篇非常详细的帖子。在那里,您将了解如何为 Silverlight 执行 Visual Studio 和 Blend 设计时的工作。

    控件供应商和编写自定义控件的人经常发现自己希望能够为其自定义控件提供更好的体验。 然而,关于这个话题的公开信息非常缺乏。我决定用这篇 50 多页的短文来纠正这种情况。

    就像我说的,它很长。 :)

    【讨论】:

      【解决方案2】:

      要检查的具体属性是DesignerProperties:

      using System.ComponentModel.DesignerProperties
      
      if (DesignerProperties.GetIsInDesignMode(this))
      {
      }
      

      其中thisDependencyObject(任何视觉元素)。

      【讨论】:

      • 谢谢 - 我花了很长时间才在谷歌中提出正确的问题才能得到这个答案...... ;-)
      猜你喜欢
      • 2010-10-21
      • 2011-01-07
      • 1970-01-01
      • 2011-03-22
      • 2010-11-29
      • 1970-01-01
      • 2011-07-17
      • 2010-09-12
      • 1970-01-01
      相关资源
      最近更新 更多