Reputation: 21449
I have an Image control that is supposed to do a slide show. Here are the binding I used to achieve this:
Binding mapBinding = new Binding();
mapBinding.Source = slideView;
mapBinding.Path = new PropertyPath("ImageDrawing");
sliderImage.SetBinding(System.Windows.Controls.Image.SourceProperty, mapBinding);
And a class SlideImage
public class SlideImage : INotifyPropertyChanged {
public ImageSource ImageDrawing{get;set;}
public void ChangeImage(){
// Load another image
// Update ImageDrawing
// Fire property changed event
}
public event PropertyChangedEventHandler PropertyChanged;
}
I found many examples on the net using the UpdateSourceTrigger
to listen for data source changes. The only problem is the Image
control does not have that property.
How do I hook up my sliderImage
control to update on SlideImage.PropertyChanged
?
Upvotes: 0
Views: 382
Reputation: 59151
It probably will update automatically, if you're actually calling PropertyChanged
when calling the setter of ImageDrawing
.
You aren't firing PropertyChanged
for your ImageDrawing
property in the code you've provided. Try this:
private ImageSource imageDrawing;
public ImageSource ImageDrawing
{
get { return imageDrawing; }
set
{
imageDrawing = value;
RaisePropertyChanged("ImageDrawing");
}
}
private void RaisePropertyChanged(string propertyName)
{
if(PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
Upvotes: 2