I have a ListView
with different DataTemplate
s set up to bind. I want to update some of the columns (mix of textblock and progress bar) when I call UpdateSource()
on a bindingexpression. I also want to update 1 of the columns when the property is changed which it is bound too.
I was able to get the PropertyChanged
behaviour to work. But whenever I change the property of one of the other columns they update straight await, instead of on the UpdateSource
call. It would appear that its ignoring the UpdateSourceTrigger
which is set in the xaml and is using the default behaviour.
I have a class which implements the INotifyPropertyChanged
interface.
The xaml for the column I want to update explicitly looks like this:
<GridViewColumn Width="300" Header="Percentage" DisplayMemberBinding="{Binding Percentage, UpdateSourceTrigger=Explicit}" />
And the xaml for one which I want to update on property change:
<GridViewColumn Header="Status" Width="150" DisplayMemberBinding="{Binding Status, UpdateSourceTrigger=PropertyChanged}" />
My binding is set originally like so:
Binding downloadBinding = new Binding();
downloadBinding.Source = _downloads;
ListDownloads.SetBinding(ListView.ItemsSourceProperty, downloadBinding);
If I execute the following code:
_downloads[0].Percentage += 0.3;
_downloads[0].FileSize = 700.00;
_downloads[1].Percentage += 10;
The column percentage column is updated straight away, but I would expect it to wait for the call on UpdateSource().
My code for updating the source is:
BindingExpression be = ListDownloads.GetBindingExpression(ListView.ItemsSourceProperty);
be.UpdateSource();
Am I missing something? I can't find anything online or in a book about why this is happening.
Cheers
I think you're confusing the source and the target... the source is your _downloads
collection, the target is the GridViewColumn
. The UpdateSourceTrigger
property controls when the source is updated by the control, but I assume your grid it not editable, so you don't need to use this property.
The update of the target is always immediate, there is no UpdateTargetTrigger
property...