Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
615
Removing UnboundField from XamDataGrid
posted

Due to some reasons I am using unbound fields to create columns in my XamDataGrid. These unbound fields use a databinding to show data.

UnboundField unboundField = new UnboundField
{
   BindingPath = new PropertyPath("Values[" + columnIndex + "].Value"),
   BindingMode = BindingMode.TwoWay
}

In addition to that I am binding a ObservableCollection<RowData> to the XamDataGrid, which has the property Values (an array of objects) that is used in the binding of the unbound fields.

When I now remove a column from my collection of row data (e.g. remove the last element in the Values array of all row datas), I am getting an exception in the output window, because the unboundField in the XamDataGrid references to an entry in the Values property that does not exist anymore.

Then I tried to remove the unboundField form the fields collection of the XamDataGrid before removing the data from my Values array. But this seems to work neither.

So, how can I remove a unboundField correctly?

thanks, Florian