Я реализовал редактируемые ListBox
элементы, как это опубликовано в этом ответе Встроенное редактирование TextBlock в ListBox с шаблоном данных (WPF)
.
Но новое значение не обновляется в объекте ItemsSource
моего ListBox.
Это XAML:
<ListBox Grid.Row="2" Name="ds_ConfigProfiles" ItemsSource="{Binding ConfigProfiles}" SelectedItem="{Binding ActiveConfigProfile}" IsSynchronizedWithCurrentItem="True" Panel.ZIndex="-1">
<ListBox.ItemTemplate>
<DataTemplate>
<!-- TODO: this is meant for allowing edit of the profile names, but the new name does not get stored back to ConfigProfiles -->
<local:TextToggleEdit Text="{Binding Path=., Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" MinWidth="40" Height="23" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Это свойство ConfigProfiles
в модели представления:
/// <summary>Configuration profiles that were found in the active storage path</summary>
public ObservableCollection<string> ConfigProfiles { get; private set; } = new ObservableCollection<string>();
Я что-то не так понял?
Может быть причина в том, что источник предметов имеет тип ObservableCollection<string>
вместо ObservableCollection<ProperClassImplementation>
(что по наследству).
Я относительно новичок в WPF и не знаю, как это отладить.