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
330
Control in grid and DataContext issue
posted

Hello,

We dynamically generate controls based on existing controls on our page and place them in the XamDataGrid. Our problem is this, our controls require our DataContext to be set on them and they are instead getting a DataRecord set as their DataContext. The DataRecord's DataItem is only the current item on our CollectionView and we need the DataItem to be our collectionview itself since we bind to properties directly on it. Is there any way around having the DataContext set to a DataRecord? As of right now, we are binding the controls DataContext to the CollectionView itself, but it still gets set to the DataRecord before our binding kicks in and this is unwanted.

Also, some of our styles (same style in and out of grid)  setters in them with bindings as their values. These bindings expect the DataContext to be our CollectionView and not a DataRecord. If we left the DataRecord as the DataContext, we can no longer can bind directly to the CollectionView.

Hopefully this makes sense. Does anyone have a solution to this issue?

Thanks.