Reputation: 1107
I have a problem updating my Combobox. I've implemented INotifyPropertyChanged. Everything is working great, it's binded. So this is my Combobox:
<ComboBox Grid.Column="1" Grid.Row="0"
ItemsSource="{Binding Path=Documents, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True,Mode=TwoWay}"
DisplayMemberPath="BrDokumentaDatum"
SelectedValuePath="IdDokumenta"
SelectedItem="{Binding Path=CurrentDocument, UpdateSourceTrigger=PropertyChanged}"
IsSynchronizedWithCurrentItem="True"
SelectedIndex="0">
</ComboBox>
This is my ViewModel:
private ObservableCollection<Dokument> documents;
public ObservableCollection<Dokument> Documents
{
get
{
return this.documents;
}
set
{
this.documents = value;
OnPropertyChanged("Documents");
}
}
I have a Command which is binded to my button
public ICommand DeleteDocumentCommand
{
get
{
if (this.deleteDocumentCommand == null)
{
this.deleteDocumentCommand = new CommandBase(i => this.DeleteDocument(), null);
}
return this.deleteDocumentCommand;
}
}
DeleteDocument() calls my service:
private void DeleteDocument()
{
if (confirm("Želite li obrisati odabrani dokument", "Obriši dokment"))
{
bool deleted = serviceClient.DeleteDocument(this.CurrentDocument.IdDokumenta);
}
}
My Document is deleted. My combobox does not update with new item source. What's the problem?
Upvotes: 0
Views: 197
Reputation: 49965
I'm not seeing any code there that removes the Dokument
from the Documents
ObservableCollection.
You can delete it from the underlying data repository, but the Documents
property is totally disconnected from that and will still hold a copy of the data entity.
Upvotes: 2