/// <summary> /// checked -> unchecked state /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ToggleButton_Unchecked(object sender, RoutedEventArgs e) { Image image = new Image(); Uri uri = new Uri(SearchImageUri, UriKind.Relative); // Gif is not working ImageSource img = new System.Windows.Media.Imaging.BitmapImage(uri); SearchToggleButtonImage.SetValue(Image.SourceProperty, img); this.PromptText = savedSearchTextBoxText; if (fireExternalEvent) { StopSearch(); } else { fireExternalEvent = true; } }
private void TryToSearch() { // If search text is empty the button goes to checked state. We: // (1) wont't send search request // (2) won't change the image // (3) Change the state to unchecked state if (string.IsNullOrEmpty(SearchTextBox.Text) || SearchTextBox.Text == savedSearchTextBoxText) { fireExternalEvent = false; SearchToggleButton.IsChecked = false; } else { Image image = new Image(); Uri uri = new Uri(StopImageUri, UriKind.Relative); ImageSource img = new System.Windows.Media.Imaging.BitmapImage(uri); SearchToggleButtonImage.SetValue(Image.SourceProperty, img); StartSearch(); } }