【发布时间】:2009-10-16 16:55:39
【问题描述】:
我已经设置了一个网格并将其绑定到一个集合。我可以通过我的网格编辑集合中的项目,并将更改传播到集合。而且,GUI 会在设置 ItemSource 时显示集合中的所有内容。但是,我正在以编程方式更改集合中的一些项目(在设置 ItemSource 之后),这些更改不会反映在网格/GUI 中。为了让它刷新,我还需要做些什么。仅供参考,对于我要编辑的字段(MoveToResource、ResourceKey 和资源类型),我已将模式设置为 TwoWay。下面是我的网格。
<ListView Name="lstXAMLStrings" Margin="5" Grid.Row="1">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Extract?">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox Content="" IsChecked="{Binding Path=MoveToResource, Mode=TwoWay}" ></CheckBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Text">
<GridViewColumn.CellTemplate>
<DataTemplate>
<local:RichTextBlock RichText="{Binding Path=FormattedMatchedLines}" TextWrapping="Wrap" Width="650"></local:RichTextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Key Name">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=ResourceKey, Mode=TwoWay}" Width="150"></TextBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Resource Type">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Source={StaticResource odp}}" SelectedItem="{Binding Path=Resource, Mode=TwoWay}"></ComboBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
【问题讨论】:
标签: c# wpf data-binding collections