【发布时间】:2012-02-21 12:03:48
【问题描述】:
我有一个看起来像这样的 WPF 代码。
public class AlphaProductesVM : BaseModel
{
private ObservableCollection<Alphabetical_list_of_product> _NwCustomers;
private int i = 0;
public AlphaProductesVM ()
{
_NwCustomers = new ObservableCollection<Alphabetical_list_of_product>();
var repository = new NorthwindRepository();
repository
.GetAllProducts()
.ObserveOn(SynchronizationContext.Current)
.Subscribe(AddElement);
}
public void AddElements(IEnumerable<Alphabetical_list_of_product> elements)
{
foreach (var alphabeticalListOfProduct in elements)
{
AddElement(alphabeticalListOfProduct);
}
}
public ObservableCollection<Alphabetical_list_of_product> NwCustomers
{
get { return _NwCustomers; }
set { _NwCustomers = value; }
}}
我使用 Unity 解决上述AlphaProductesVM。当使用 PRISM 和 UnityBootstrapper 发现模块时,这是即时的。在运行时.ObserveOn(SynchronizationContext.Current) 抛出一个异常,SynchronizationContext.Current 中有一个null 值。
【问题讨论】:
标签: c# wpf mvvm unity-container system.reactive