更新后列表视图不会改变
我有一个带有可观察集合源的列表视图。我确信数据在后面的代码中发生了变化,但我完全筋疲力尽为什么用户界面不会显示更改。我缺少什么?
我的 xaml:
<GridViewColumn Width="70" Header="Status">
<GridViewColumn.CellTemplate>
<DataTemplate>
<!--<CheckBox IsChecked="{Binding Path=Status, Mode= Twoway}" HorizontalContentAlignment="Center" IsEnabled="False"/>-->
<TextBlock Text="{Binding Path=Status, Mode= Twoway}" TextAlignment="Center" Loaded="Page_Loaded"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
我的班级:
public partial class tblADRMaster: INotifyPropertyChanged
{
public string Status
{
get { return _status; }
set
{
if (_status != value)
{
_status = value;
OnPropertyChanged("Status");
}
}
}
}
这是我的代码:
ObservableCollection<tblADRMaster> list = new ObservableCollection<tblADRMaster>();
CurrentCase = FileMaintenanceBusiness.Instance.GetADRMasterInfobyKeywordRefresh(caseNo.CaseIDSystem, "CaseIDSystem");
foreach (var c in listFrWWC)
{
if (c.CaseIDSystem != CurrentCase.CaseIDSystem)
list.Add(c);
else
list.Add(CurrentCase);
}
foreach (var caseMaster in list)
{
caseMaster.IsMissingDocs = GetMissingDoc(caseMaster.tblADRDispositions);
caseMaster.IsProblemCase = !string.IsNullOrEmpty(caseMaster.ProblemNote) ? "Yes" : "No";
caseMaster.Status = GetStatus(caseMaster);
}
lvAdrMaster.ItemsSource = list;
我想更改状态。它确实发生了变化,因为我放置了一个断点,并且状态从“保持”变为“活动”,但列表视图不会显示更改。它保持保持状态,除非我按返回按钮或重新加载项目。
我一整天都在解决这个问题,我似乎想不出还有什么我可能错过的事情。请告诉我。谢谢。
I have a listview with observable collection source. I am sure the data changed in code behind but I am totally exhausted why the UI won't display the changes. What am I missing?
My xaml:
<GridViewColumn Width="70" Header="Status">
<GridViewColumn.CellTemplate>
<DataTemplate>
<!--<CheckBox IsChecked="{Binding Path=Status, Mode= Twoway}" HorizontalContentAlignment="Center" IsEnabled="False"/>-->
<TextBlock Text="{Binding Path=Status, Mode= Twoway}" TextAlignment="Center" Loaded="Page_Loaded"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
My class:
public partial class tblADRMaster: INotifyPropertyChanged
{
public string Status
{
get { return _status; }
set
{
if (_status != value)
{
_status = value;
OnPropertyChanged("Status");
}
}
}
}
This is my code behind:
ObservableCollection<tblADRMaster> list = new ObservableCollection<tblADRMaster>();
CurrentCase = FileMaintenanceBusiness.Instance.GetADRMasterInfobyKeywordRefresh(caseNo.CaseIDSystem, "CaseIDSystem");
foreach (var c in listFrWWC)
{
if (c.CaseIDSystem != CurrentCase.CaseIDSystem)
list.Add(c);
else
list.Add(CurrentCase);
}
foreach (var caseMaster in list)
{
caseMaster.IsMissingDocs = GetMissingDoc(caseMaster.tblADRDispositions);
caseMaster.IsProblemCase = !string.IsNullOrEmpty(caseMaster.ProblemNote) ? "Yes" : "No";
caseMaster.Status = GetStatus(caseMaster);
}
lvAdrMaster.ItemsSource = list;
I want to change the status. It does change coz I placed a breakpoint and STATUS went from HOLD to ACTIVE but the listview won't display the change. it remains HOLD, unless I press back btn or reload the items.
I have been troubleshooting this all day and I cannot seem to think of anything else I could have missed. Pls tell me. thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试对您的文本块绑定进行此操作:
Try this for your textblock binding:
尝试使用 CollecitonViewSource
并在更新集合后刷新 collectionViewSource
喜欢
Try to use CollecitonViewSource
and after u update the collection just refresh the collectionViewSource
like
您是否在
tblADRMaster
类中实现了INotifyPropertyChanged
接口并为Status
属性引发了属性通知?Have you implemented
INotifyPropertyChanged
interface intblADRMaster
class and raised property notification forStatus
property?