[英]WPF DataGrid: How to perform column binding using code behind?
This is the column in question: 这是有问题的专栏:
<DataGridTextColumn
Header=" Length "
Width="Auto"
Binding="{Binding Path=Length, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, StringFormat=0.00;;#}"
ElementStyle="{StaticResource RightJustified}"
x:Name="lengthColumn">
</DataGridTextColumn>
The problem is that I need to bind that column to some other property (called Length48
) at run time. 问题是我需要在运行时将该列绑定到其他属性(称为Length48
)。
TIA. TIA。
Try this: 尝试这个:
DataGridTextColumn dataGridTextColumn = new DataGridTextColumn();
dataGridTextColumn.Header = " Length ";
dataGridTextColumn.Binding = new Binding("Length48");
YourDataGrid.Columns.Add(dataGridTextColumn);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.