【使用vs2010&表情混合v4】
嗨 - 尝试在 WPF 和 Blend 中加载一些设计时数据,在这里使用 Josh Smith 的概念:http: //joshsmithonwpf.wordpress.com/2010/04/07/assembly-level-initialization-at-design-time/ 例如
[AttributeUsage(AttributeTargets.Assembly)]
public class DesignTimeBootstrapperAttribute : Attribute
{
public DesignTimeBootstrapperAttribute(Type type)
{
var dep = new DependencyObject();
Debug.WriteLine("here..?");
if (DesignerProperties.GetIsInDesignMode(dep))
{
// TODO: Design-time initialization…
IBootstrapper instance = Activator.CreateInstance(type) as IBootstrapper;
if (instance != null)
{
instance.Run();
}
}
}
}
使用我在 AssemblyInfo.cs 中的属性,其中 AppBootstrapper 扩展了 MefBootstrapper。
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: DesignTimeBootstrapper(typeof(AppBootstrapper))]
我不想使用 Blend 示例数据,a) 因为它似乎没有为 ObservableCollection 创建数据,b) 根据定义我处于设计模式,所以事情会发生很大变化,但是我的“生成的数据” ' 将不会。
无论如何,似乎什么都没有发生。
Q1:如何调试我的引导程序的设计时初始化?Q2:我的 View XAML 中是否需要额外的混合命名空间/属性等?
(在我的引导程序中,我只是注册了一个不同的模块,我想用 DesignTimeService 替换 RunTimeService,导出 IService 接口)。
TIA