[sử dụng VS2010 & biểu hiện sự pha trộn v4]dữ liệu thời gian thiết kế trong WPF
Hi - cố gắng để tải lên một số dữ liệu thời gian thiết kế trong WPF và Blend, sử dụng khái niệm Josh Smith ở đây: http://joshsmithonwpf.wordpress.com/2010/04/07/assembly-level-initialization-at-design-time/ ví dụ
[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();
}
}
}
}
Với thuộc tính của tôi ở đây trong AssemblyInfo.cs, nơi AppBootstrapper mở rộng MefBootstrapper.
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: DesignTimeBootstrapper(typeof(AppBootstrapper))]
Tôi không muốn sử dụng dữ liệu mẫu Trộn, a) dường như không tạo dữ liệu cho ObservableCollection và b) Tôi đang ở chế độ thiết kế theo định nghĩa, vì vậy mọi thứ sẽ thay đổi hoàn toàn rất nhiều, nhưng 'dữ liệu được tạo' của tôi sẽ không.
Dù sao, dường như không có gì xảy ra.
Q1: Làm thế nào để gỡ lỗi thời gian thiết kế của bootstrapper của tôi? Q2: Tôi có cần thêm các vùng tên/thuộc tính kết hợp v.v. trong XAML của tôi không?
(Trong bootstrapper của tôi, tôi chỉ đăng ký một mô-đun khác mà tôi muốn thay thế RunTimeService bằng một DesignTimeService, xuất giao diện IService).
TIA
Các bạn đã thành công trong việc đưa ra đoạn mã này hoạt động? – EngineerSpock