private static void EffectChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var uiSender = d as UIElement; var effect = e.NewValue as IComposition; effect.Initialize(uiSender); }
private static void OnMessageChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var notifybar = d as NotificationBar; var message = e.NewValue as string; if (message == string.Empty) return; notifybar?.ShowMessage(message); }
private static async void SizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if ((int)e.NewValue <= 0) throw new ArgumentException("ThumbImageSource width/height 必须大于0"); var thumb = (ThumbImageSource)d; //await thumb.Deal(); }
// 依存関係プロパティに値がセットされたときに呼び出されるメソッド private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var i = d as TwitterSuggestTextBox; i.textBoxTweet.Text = (string)e.NewValue; // i.model.Text = (string)e.NewValue; }
private static void OnMaskChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var target = (TextBoxMaskBehavior)sender; var oldMask = (TextMask)e.OldValue; var newMask = (TextMask)e.NewValue; target.OnMaskChanged(oldMask, newMask); }
private static void OnHeaderTemplatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var source = d as HeaderedItemsControl; var oldHeaderTemplate = e.OldValue as DataTemplate; var newHeaderTemplate = e.NewValue as DataTemplate; if (source != null) source.OnHeaderTemplateChanged(oldHeaderTemplate, newHeaderTemplate); }
static void PositionChanged(DependencyObject dp, DependencyPropertyChangedEventArgs args) { var p = ((FrameworkElement)dp)?.Parent; if (p == null) return; ((UIElement)p)?.InvalidateArrange(); }
private static void OnBaterryPercentagePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var obj = (BatteryPercentageTrigger)d; var val = (BaterryPercentageState)e.NewValue; obj.SetActive(val == _batteryPercentageState); }
/// <summary> /// RatioVisibleProperty property changed handler. /// </summary> /// <param name="d">PartialView that changed its RatioVisible.</param> /// <param name="e">Event arguments.</param> private static void OnRatioVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Clipper source = (Clipper)d; double oldValue = (double)e.OldValue; double newValue = (double)e.NewValue; source.OnRatioVisibleChanged(oldValue, newValue); }
/// <summary> /// ExpandDirectionProperty property changed handler. /// </summary> /// <param name="d">ExpandDirectionView that changed its ExpandDirection.</param> /// <param name="e">Event arguments.</param> private static void OnExpandDirectionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { LinearClipper source = (LinearClipper)d; ExpandDirection oldValue = (ExpandDirection)e.OldValue; ExpandDirection newValue = (ExpandDirection)e.NewValue; source.OnExpandDirectionChanged(oldValue, newValue); }
private static void OnSearchTermChanged(DependencyObject d, DependencyPropertyChangedEventArgs args) { var textBlock = (TextBlock)d; if (textBlock == null) return; var searchTerm = GetSearchTerm(textBlock); var originalText = GetSearchText(textBlock); if (string.IsNullOrEmpty(originalText) || (searchTerm == null)) return; if (searchTerm.Length == 0) { textBlock.Text = originalText; return; } textBlock.Inlines.Clear(); var currentIndex = 0; var searchTermLength = searchTerm.Length; int index = originalText.IndexOf(searchTerm, 0, StringComparison.CurrentCultureIgnoreCase); while (index > -1) { textBlock.Inlines.Add(new Run() { Text = originalText.Substring(currentIndex, index - currentIndex) }); currentIndex = index + searchTermLength; textBlock.Inlines.Add(new Run() { Text = originalText.Substring(index, searchTermLength), Foreground = GetHighlightBrush(textBlock) }); index = originalText.IndexOf(searchTerm, currentIndex, 0, StringComparison.CurrentCultureIgnoreCase); } textBlock.Inlines.Add(new Run() { Text = originalText.Substring(currentIndex) }); }
private static void OnSecondsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var target = (CountdownControl)sender; var oldSeconds = (int)e.OldValue; var newSeconds = (int)e.NewValue; target.OnSecondsChanged(oldSeconds, newSeconds); }
private static void OnButtonForegroundColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var color = (Color)e.NewValue; var titleBar = ApplicationView.GetForCurrentView().TitleBar; titleBar.ButtonForegroundColor = color; }
/// <summary> /// Handles the HTML has changed, converts it and attach to the attached RichTextBlock. /// </summary> /// <param name="d">The RichTextBlock.</param> /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param> private static async void HtmlChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { RichTextBlock richText = d as RichTextBlock; string html = e.NewValue as string; if (richText != null && !string.IsNullOrEmpty(html)) { try { if (!ContainsHtmlTags(html)) { html = html.Replace("\r\n", "<br/>"); html = html.Replace("\n\r", "<br/>"); html = html.Replace("\n", "<br/>"); } string xaml = await Html2XamlProcessor.ConvertToXaml(html); ChangeRichTextBlockContents(richText, xaml); } catch (Exception ex) { Debug.WriteLine(ex); try { ChangeRichTextBlockContents(richText, GetErrorXaml(ex, html)); } catch { Debug.WriteLine(ex); } } } }
private static void OnPathChanged( DependencyObject obj, DependencyPropertyChangedEventArgs args ) { var icon = (Icon) obj; var data = (string) args.NewValue; if ( data == null ) { return; } // Copy it since sharing it isn't permitted var path = (Path) XamlReader.Load( "<Path xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Data=\"" + data + "\" />" ); path.Stretch = Stretch.Uniform; path.HorizontalAlignment = HorizontalAlignment.Center; path.VerticalAlignment = VerticalAlignment.Center; path.SetBinding( Path.FillProperty, new Binding { Source = icon, Path = new PropertyPath( "Foreground" ) } ); path.SetBinding( Path.MarginProperty, new Binding { Source = icon, Path = new PropertyPath( "Padding" ) } ); var container = new Border { Child = path }; container.SetBinding( Border.WidthProperty, new Binding { Source = icon, Path = new PropertyPath( "IconWidth" ) } ); container.SetBinding( Border.HeightProperty, new Binding { Source = icon, Path = new PropertyPath( "IconHeight" ) } ); container.SetBinding( Border.BackgroundProperty, new Binding { Source = icon, Path = new PropertyPath( "Background" ) } ); icon.HorizontalAlignment = HorizontalAlignment.Center; icon.VerticalAlignment = VerticalAlignment.Center; icon.Content = new Viewbox { Child = container }; }
private static void VisualStateNarrowMinWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { //if (!Equals(e.NewValue, -1) && XamlUtils.Ancestor<HamburgerMenu>(d as Control) == null) //{ // (d as PageHeader).VisualStateNarrowMinWidth = -1; //} }
private static void OnSelectedIndexPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var item = (int)(e.NewValue); var ctrl = (SidePanel)d; if (item < ctrl.Items.Count) ctrl.SelectedItem = ctrl.Items[item]; }
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (e.NewValue != null) (d as ExtendedTextBox).TextChanged += ExtendedTextBox_TextChanged; else (d as ExtendedTextBox).TextChanged -= ExtendedTextBox_TextChanged; }
private static void OnEndAngleChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var target = (PieSlice)sender; var oldEndAngle = (double)e.OldValue; var newEndAngle = (double)e.NewValue; target.OnEndAngleChanged(oldEndAngle, newEndAngle); }
/// <summary> /// Handles changes to the Cursor property. /// </summary> /// <param name="d"> /// The <see cref="DependencyObject"/> on which /// the property has changed value. /// </param> /// <param name="e"> /// Event data that is issued by any event that /// tracks changes to the effective value of this property. /// </param> private static void OnCursorChanged( DependencyObject d, DependencyPropertyChangedEventArgs e) { CoreCursor oldCursor = (CoreCursor)e.OldValue; CoreCursor newCursor = (CoreCursor)d.GetValue(CursorProperty); if (oldCursor == null) { var handler = new CursorDisplayHandler(); handler.Attach((Control)d); SetCursorDisplayHandler(d, handler); } else { var handler = GetCursorDisplayHandler(d); if (newCursor == null) { handler.Detach(); SetCursorDisplayHandler(d, null); } else { handler.UpdateCursor(); } } }
private static void OnNetworkStatusPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var obj = (NetworkStatusTrigger)d; var val = (NetworkStatus)e.NewValue; obj.SetActive(val == _status); }
private static void MessageTextForegroundColorPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) { NotificationView ctl = (NotificationView)obj; ctl.lblMessage.Foreground = (Brush)args.NewValue; }
private static void SearchBoxChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var textBox = d as TextBox; if (textBox == null) throw new InvalidCastException("This extension is for TextBox only"); var searchBox = e.NewValue as SearchBox; if (searchBox == null) return; searchBox.QuerySubmitted += (s, args) => { var text = args.QueryText; if (string.IsNullOrEmpty(text)) { textBox.SelectionLength = 0; return; } var index = textBox.Text.IndexOf(text); if (index < 0) { textBox.SelectionLength = 0; return; } textBox.SelectionStart = index; textBox.SelectionLength = text.Length; if (textBox.FocusState == FocusState.Unfocused) textBox.Focus(FocusState.Programmatic); }; }
private static void OnLocomotiveChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ucLocomotiveEditor uc = d as ucLocomotiveEditor; if ((e.NewValue as Locomotive) != null) uc.InitProtocolList(); }
private static void OnTextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var target = (TextBoxMaskBehavior)sender; var oldText = (string)e.OldValue; var newText = (string)e.NewValue; target.OnTextChanged(oldText, newText); }
private static async void OnCacheUriChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { //Uri oldCacheUri = (Uri)e.OldValue; Uri newCacheUri = (Uri)d.GetValue(CacheUriProperty); var image = (Image)d; if (newCacheUri != null) { try { //Get image from cache (download and set in cache if needed) var cacheUri = await WebDataCache.GetLocalUriAsync(newCacheUri); //Set cache uri as source for the image image.Source = new BitmapImage(cacheUri); } catch (Exception ex) { Debug.WriteLine(ex); //Revert to using passed URI image.Source = new BitmapImage(newCacheUri); } } else image.Source = null; }
private static void OnCommandPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var control = d as FrameworkElement; if (control != null) control.Tapped += OnTapped; }
private static void OnCommandPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var control = d as ListViewBase; if (control != null) control.ItemClick += OnItemClick; }
private static void OnMaximumChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { var target = (PercentRingSlice)sender; var oldMaximum = (double)e.OldValue; var newMaximum = (double)e.NewValue; target.OnMaximumChanged(oldMaximum, newMaximum); }
private async static void UriSourcePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e) { Debug.WriteLine("我被触发了"); StorageCachedImage image = d as StorageCachedImage; string i = e.NewValue as string; int k = i.IndexOf("image"); string imagePath = i.Substring(k + 7); string uri = App.Uri + "public/images/" + imagePath; Debug.WriteLine(uri); Uri imageUri = new Uri(uri); HttpClient client = new HttpClient(); var response = await client.GetAsync(imageUri); var buffer = await response.Content.ReadAsBufferAsync(); var memoryStream = new InMemoryRandomAccessStream(); await memoryStream.WriteAsync(buffer); await memoryStream.FlushAsync(); await image.SetSourceAsync(memoryStream); }