我得到了一个ItemsControl
包含Expander
在其中Expander
的视图ProgressBars
。我的问题是当我加载数据时(这不是我的性能问题),然后我更新ItemSource
我的 gui 的 PropertyChanged 冻结了很长时间,因为它需要很长时间才能渲染。
有没有办法让我的 gui 元素异步变红,这样我的 gui 就不会冻结???我已经搜索了一下,但我不确定我的搜索结果是否能解决我的问题。所以我在这里问,希望有一个很好的解决方案。
他们的 gui 确实看起来像这样.. 虽然通常有更多的元素 你都可以想象背后的 xaml 代码......
private void RefreshOverview(){
...
foreach (Characteristic c in characteristics)
{
Area a = c.Area;
Characteristic c1 = c;
foreach (Line l in lines.Where(l => l.Product.Id == c1.Product.Id))
{
List<IMeasurementSchedule> measurementSchedules;
// take DefaultMeasurementSchedules if exists
if (c.DefaultMeasurementSchedules == null || c.DefaultMeasurementSchedules.Count == 0)
measurementSchedules = new List<IMeasurementSchedule>(l.LineMeasurementSchedules.ToArray());
else
measurementSchedules = new List<IMeasurementSchedule>(c.DefaultMeasurementSchedules.ToArray());
foreach (IMeasurementSchedule ms in measurementSchedules)
{
MeasureCharacteristic mc;
if (a.PeripheryEnabled)
{
Line l1 = l;
foreach (AreaItem ai in areaitems.Where(x => x.AreaId == a.Id && x.LineId == l1.Id))
{
mc = (from cm in _context.CharacteristicMeasures.Local
where cm.Charge == null &&
cm.Characteristic.Id == c.Id &&
cm.Line.Id == l.Id &&
cm.ShiftIndex.Id == actualShiftIndex.Id &&
cm.AreaItem != null &&
cm.AreaItem.Id == ai.Id &&
cm.MeasureScheduleId == ms.Id
select cm).FirstOrDefault() ??
new MeasureCharacteristic
{
Characteristic = c,
Line = l,
ShiftIndex = actualShiftIndex,
AreaItem = ai
};
mc.MeasureSchedule = ms;
characteristicsMeasures.Add(AddMeasures(mc));
}
}
else
{
mc = (from cm in _context.CharacteristicMeasures.Local
where cm.Charge == null &&
cm.Characteristic.Id == c.Id &&
cm.Line.Id == l.Id &&
cm.ShiftIndex.Id == actualShiftIndex.Id &&
cm.MeasureScheduleId == ms.Id
select cm).FirstOrDefault() ??
new MeasureCharacteristic {Characteristic = c, Line = l, ShiftIndex = actualShiftIndex};
mc.MeasureSchedule = ms;
characteristicsMeasures.Add(AddMeasures(mc));
}
}
}
}
MeasureCharacteristics = characteristicsMeasures;
MeasureCharacteristicsByType =
CharacteristicMeasureGroupedByType.GetExpanderViewProductItems(characteristicsMeasures);
}
这就是我的代码;) MeasureCharacteristicsByType 是IEnumerable<CharacteristicMeasureGroupedByType>
我将我的 itemsource 绑定到的。如果您需要更多信息,请询问!!!
更新
这是我的 xaml 代码的链接.. http://pastebin.com/UA777LjW