Hello,
I'm having a little issue with unbound columns. When defining a DataTemplate for the cell in an unbound column, the ContentPresenter for some unknown reason has the DataContext property set to some TextBlock.
All the other components of the cell style has the expected UnboundColumnDataContext.
The markup is as follows:
<Style TargetType="{x:Type ig:CellControl}" x:Key="ActionsColumnStyle"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <TextBlock Text="Test" /> </DataTemplate> </Setter.Value> </Setter></Style>
Hello Anton,
Our developers have completed their review of development issue 104770. They have determined that this is not caused by an issue in our control because the Content of the CellControl is set internally from the XamGrid and is different for display and edit mode. This is not limited to the UnboundColumn. The same will happen for any other column.
In your example the DataContext is TextBlock, because the display element of the UnboundColumn is TextBlock. When the element contained in the internal ContentPresenter is changed, it will change the DataContext, too.
Based on this I believe that you best option is to manually bind the DataContext to its ancestor’s DataContext as I already show you.
If you have any further questions or concerns on this matter, please let me know.
I have asked our engineering team to examine this further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of 104770 The next step will be for a developer to review my investigation and confirm my findings or to offer a fix, or other resolution. I have also created a support ticket for you about this in our system with number CAS-86619-G046HL, in order to link the development issue, so you can be automatically notified as soon as our developers conclude their investigation on this matter.
Please let me know if you need more information.
I succeed in reproducing the issue that you are referring and I am going to forward this to our engineering team. Still if you want the TextBlock from your DataTemplate to inherit the UnboundColumnDataContext for now you can just set the following binding to it:
DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type igPrim:CellsPanel}}, Path=DataContext}"
Please let me know if you have any additional concerns on this matter.