我在尝试刷新 Gridview 中的数据时遇到问题,问题是如果我的应用程序正在运行并且我更新了数据库上的某些内容,则新数据不会刷新,但如果我关闭应用程序并再次重新运行,则会出现更改。
这是我在构造函数中的一段代码:
IQueryable<GyLoadCarrier> loadCarrierQuery = queryRepository.GetGyLoadCarriers();
LoadCarriersMfsTransportsLoader = new WcsDomainCollectionViewLoader<GyLoadCarrier>(loadCarrierQuery)
{
RequestTotalItemCount = true
};
LoadCarriersMfsTransportsLoader.LoadStarted += OnLoadCarrierMfsTransportsLoaderLoadStarted;
LoadCarriersMfsTransportsLoader.LoadCompleted +=OnLoadCarrierMfsTransportsLoaderLoadCompleted;
AvailableLoadCarriers = new DomainCollectionView<GyLoadCarrier>(LoadCarriersMfsTransportsLoader,
LoadCarriersMfsTransportsLoader.Data);
LoadCarriersMfsTransportsLoader.View = AvailableLoadCarriers;
INotifyCollectionChanged notifyingSortLoadCarrierDestination = AvailableLoadCarriers.SortDescriptions;
notifyingSortLoadCarrierDestination.CollectionChanged += (sender, e) => AvailableLoadCarriers.MoveToFirstPage();
using (AvailableLoadCarriers.DeferRefresh())
{
AvailableLoadCarriers.PageSize = 30;
AvailableLoadCarriers.MoveToFirstPage();
}
LoadCarriersMfsTransportsLoader.Load("LoadCarrierAddressChanged");
刷新命令只是:
protected override void OnRefresh()
{
MfsTransportsLoader.Load(Resources.Strings.LoadingMfsTransportsProgressMessage);
}
所以知道为什么会这样吗?