【发布时间】:2014-03-17 21:57:47
【问题描述】:
当我尝试将行设置为等于用户选择的行时,我收到了标题中所述的错误。此行发生错误:
DataGridRow row = e.Row as DataGridRow;
错误信息:无法转换类型 'ExtendedGrid.Microsoft.Windows.Controls.DataGridRow' 到 'System.Windows.Controls.DataGridRow' 通过引用转换, 装箱转换、拆箱转换、包装转换,或为空 类型转换
我正在使用 WPF 扩展数据网格。以下是 RowDetailsVisibilityChanged 事件的源代码:
private void RowDetailsVisibilityChanged(object sender, ExtendedGrid.Microsoft.Windows.Controls.DataGridRowDetailsEventArgs e)
{
DataGridRow row = e.Row as DataGridRow;
FrameworkElement tb = GetTemplateChildByName(row, "RowHeaderToggleButton");
if (tb != null)
{
if (row.DetailsVisibility == System.Windows.Visibility.Visible)
{
(tb as ToggleButton).IsChecked = true;
}
else
{
(tb as ToggleButton).IsChecked = false;
}
}
}
有什么建议吗?
【问题讨论】: