static void AttachButton(BalloonPopup popup, Button trigger) { Window owner = Window.GetWindow(trigger); trigger.Click += delegate { popup.TryOpen(); }; if (owner != null) { owner.LocationChanged += delegate { popup.TryClose(); }; owner.SizeChanged += delegate { popup.TryClose(); }; } }
static void AttachButton(BalloonPopup popup, ToggleButton trigger) { Window owner = Window.GetWindow(trigger); Binding binding = new Binding("IsChecked"); binding.Source = trigger; popup.SetBinding(Popup.IsOpenProperty, binding); if (owner != null) { owner.LocationChanged += delegate { if (popup.StaysOpen == false) trigger.IsChecked = false; }; owner.SizeChanged += delegate { if (popup.StaysOpen == false) trigger.IsChecked = false; }; } }
static void AttachListView(BalloonPopup popup, Selector trigger) { trigger.SelectionChanged += delegate(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count == 0) return; if (popup.IsOpen) popup.TryClose(); var source = trigger.SelectedItem; var selectedItem = (ListViewItem)trigger.ItemContainerGenerator.ContainerFromItem(source); popup.PlacementTarget = selectedItem; popup.TryOpen(); }; }
public static void SetAttachedPopup(DependencyObject obj, BalloonPopup value) { obj.SetValue(AttachedPopupProperty, value); }