这是相关专栏:
<DataGridTextColumn
Header=" Length "
Width="Auto"
Binding="{Binding Path=Length, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, StringFormat=0.00;;#}"
ElementStyle="{StaticResource RightJustified}"
x:Name="lengthColumn">
</DataGridTextColumn>
问题是我需要在运行时将该列绑定到其他属性(称为Length48
)。
TIA。
答案 0 :(得分:3)
试试这个:
DataGridTextColumn dataGridTextColumn = new DataGridTextColumn();
dataGridTextColumn.Header = " Length ";
dataGridTextColumn.Binding = new Binding("Length48");
YourDataGrid.Columns.Add(dataGridTextColumn);