I am programmatically creating GridViewColumns. My columns are simple: a Grid that contains a TextBox. I set Grid.Margin and the TextBox's Tag and Style properties. I wish my GridViewColumn to look like the XAML below:
<GridViewColumn Header="MyHeader">
<GridViewColumn.CellTemplate>
<ItemContainerTemplate>
<Grid Margin="-6,0,-6,0">
<TextBox Tag="0" Style="{StaticResource PassFailStyle}"/>
</Grid>
</ItemContainerTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
question from:https://stackoverflow.com/questions/66054091/properties-disappear-when-programmatically-creating-gridviewcolumn