为什么Silverlight弹出窗口在计算时挂起?
我在silver light中创建了一个自定义日期时间控件,在我的silver light自定义控件中有属性名“EditDate”。该日期是在binder的帮助下设置的,基本上是双向绑定,当我从日期时间选择器设置编辑日期时,它很好地设置了我的外部属性,当设置外部属性时,有一个setter事件执行一些计算,现在的问题是,当计算正在进行时,我的日期时间选择器弹出窗口保持打开状态,有没有办法在设置“EditDate”后立即隐藏它 谢谢为什么Silverlight弹出窗口在计算时挂起?,silverlight,popup,Silverlight,Popup,我在silver light中创建了一个自定义日期时间控件,在我的silver light自定义控件中有属性名“EditDate”。该日期是在binder的帮助下设置的,基本上是双向绑定,当我从日期时间选择器设置编辑日期时,它很好地设置了我的外部属性,当设置外部属性时,有一个setter事件执行一些计算,现在的问题是,当计算正在进行时,我的日期时间选择器弹出窗口保持打开状态,有没有办法在设置“EditDate”后立即隐藏它 谢谢 Aman.我认为计算冻结了UI线程。将计算放在Background
Aman.我认为计算冻结了UI线程。将计算放在BackgroundWorker中,以便在处理计算时更新UI
var bw = new BackgroundWorker();
//Will fire when backgroundworker starts
bw.DoWork += (snd, arg) =>
{
//Do your calculations here
CalculationsFunction(param1, param2)
//Cannot access UI elements here
};
//Will fire when backgroundworker finishes
bw.RunWorkerCompleted += (s, arg) =>
{
//Can access the UI here again if needed
if (arg.Error != null)
{
//Show message if error
}
else
{
//Update UI here if needed
}
};
//Begins running the background worker
bw.RunWorkerAsync((this.DataContext as Iteration));
最少的例子有助于理解正在发生的事情。非常感谢。