Hello,
I'm binding my grid to a collection of RowViewModel, which are basically DynamicObjects that maintain a Dictionary<string, CellViewModel>.
I've read this article to do this : WPF DataGrid | Data Bind to Dynamic Object with CLR and Dynamic Properties | Telerik UI for WPF (even if I'm not using CLR properties at the moment).
Now the thing is, for some rows and columns, it doesn't make sense having a cell (this is business-related).
So for these rows/columns, I don't create a new entry in my row dictionary. That leads to the following Get/Set methods inherited from DynamicObject:
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
if (dic.ContainsKey(binder.Name))
{
result = dic[binder.Name];
return true;
}
result = null;
return false;
}
public override bool TrySetMember(SetMemberBinder binder, object value)
{
if (dic.ContainsKey(binder.Name))
{
dic[binder.Name].Value = value;
return true;
}
return false;
}
It seems to work well, there is no crash and it displays correctly (the concerned cells are empty).
However in my XAML Binding Failures, I have a bunch of these:
How to avoid this?
Thanks!