我的xaml代码:
<DataGrid x:Name="pRCPROFDataGrid"
EnableRowVirtualization="True"
ItemsSource="{Binding}"
RowDetailsVisibilityMode="Visible"
CanUserAddRows="True"
FlowDirection="RightToLeft" RowEditEnding="pRCPROFDataGrid_RowEditEnding"/>
我的代码c#:
DataTable tbl = lib.GetDataFromTable("SELECT column_name, data_type, nullable FROM user_tab_columns WHERE table_name = '" + _table + "' order by column_id", "Usr");
DataTable sourceTable = new DataTable();
string[] _label = lib.GetDetailsTable(_table);
for (int element = 0; element <= tbl.Rows.Count - 1; element++)
{
DataGridBoundColumn _xtemp = null;
if (tbl.Rows[element][1].ToString() == "bit")
{
_xtemp = new DataGridCheckBoxColumn();
}
else
{
_xtemp = new DataGridTextColumn();
}
_xtemp.Header = _label[element];
_xtemp.Binding = new Binding(tbl.Rows[element][0].ToString());
_grid.Columns.Add(_xtemp);
if (element == 0)
_xtemp.Visibility = Visibility.Hidden;
if (element == 1)
_xtemp.Width = new DataGridLength(1, DataGridLengthUnitType.Star);
}
_grid.ItemsSource = sourceTable.DefaultView;
结果:
附加信息:双向绑定需要Path或XPath。
System.InvalidOperationException未处理 消息:未知模块中发生未处理的“System.InvalidOperationException”类型异常。 附加信息:双向绑定需要Path或XPath。
答案 0 :(得分:0)
通过从列标题(名称)中删除斜杠解决了同样的问题。