我在我的应用程序中有一个简单的DataGrid。在源代码的某个地方,我将其
ItemsSource
属性绑定到一个ObservableCollection<System.Windows.Points>
。因此,这些点会显示在DataGrid
中。问题是,我已经设置了TwoWay
绑定,但是当在DataGrid
中更改点坐标值时,ObservableCollection
中的实际点值并没有改变!发生了什么问题?<DataGrid Name="pointList" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTemplateColumn Header="X" Width="200">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=X, Mode=TwoWay}"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Y" Width="200">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=Y, Mode=TwoWay}"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
注意:我看过这个,但我的问题不同。