Reputation: 2146
I have windows application developed based on WPF,i am going thur weird issue here. I have to chose the image ,once its done am pop up the message like ""Keyframe Image was resized successfully" but if do two times,its pop up two times though,if do it 3 times then it pop up thrice.
Am not sure how to resolve this or how to count,any help much apprciated.
here is my view model class file
private void imageResizer_ResizeCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
{
string test =e.ToString();
ImageResizerResult result = (ImageResizerResult)e.Result;
this.aggregator.GetEvent<ImageResizeCompletedEvent>().Publish(result.IsSuccessful);
if (result.IsSuccessful)
{
this.dialog.ShowSuccess("Keyframe Image was resized successfully");
}
}
is calling my service to pass this message
public void ShowSuccess(string message)
{
MessageBox.Show(message,
"Success",
MessageBoxButton.OK,
MessageBoxImage.Information);
}
Any idea what am missing here.Thanks in Advance
Upvotes: 1
Views: 988
Reputation:
I think that everytime you pick an image, you add an event to that image (or an image's controller) with the += operator. Then, somewhere in your application the ResizeComplete event is fired.
But, as you never dettach the event from the previous images, all them are fired together. You need to use the -= operator somewhere in your code, possibly inside the ResizeComplete method.
Upvotes: 2