如何将 Object[] 数组转换为 ObservableCollection在 WPF 中?
我有一个 DataGrid。我将 ObservableCollection 绑定到 DataGrid。我向它添加了分页。 为此,我将 ObservationCollection 转换为 DataTable。
我的代码是
ObservableCollection<RiskSettings> riskCollection = new ObservableCollection<RiskSettings>();
grdRiskAlerts.DataContext = riskCollection;
dTable = ToDataTable(riskCollection);
object[] obj = gridPaging.CustomPaging(dTable, (int)DataGridPaging.PagingMode.First);
grdRiskAlerts.ItemsSource = (DataView)obj[0];
txtDispRecs.Text = obj[1].ToString();
txtNumOfPages.Text = obj[2].ToString();
txtTotalRecs.Text = "Total : " + dTable.Rows.Count;
if (dTable.Rows.Count <= recPerPage)
{
brdPaging.IsEnabled = false;
}
else
brdPaging.IsEnabled = true;
我的类名称是RiskSettings。 当我右键单击所选行时,是否出现了类型转换问题。 所以我需要将 Datagrid 与类绑定而不是 (DataView)obj[0] 怎么做呢? 我尝试过,但找不到解决方案 对此有什么帮助吗? 提前致谢, 拉姆基。
I have a DataGrid.I binded ObservableCollection to DataGrid.I added paging to it.
For it I converted ObservationCollection into DataTable.
My code is as
ObservableCollection<RiskSettings> riskCollection = new ObservableCollection<RiskSettings>();
grdRiskAlerts.DataContext = riskCollection;
dTable = ToDataTable(riskCollection);
object[] obj = gridPaging.CustomPaging(dTable, (int)DataGridPaging.PagingMode.First);
grdRiskAlerts.ItemsSource = (DataView)obj[0];
txtDispRecs.Text = obj[1].ToString();
txtNumOfPages.Text = obj[2].ToString();
txtTotalRecs.Text = "Total : " + dTable.Rows.Count;
if (dTable.Rows.Count <= recPerPage)
{
brdPaging.IsEnabled = false;
}
else
brdPaging.IsEnabled = true;
My Class name is RiskSettings.
When i right Click on selected row,did operation Type Casting problem is arising.
So i need to bind Datagrid with class instead of (DataView)obj[0]
How to do it?
I tried it,But unable to find solution
Can any help on this?
Thanks in advance,
Ramki.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论