예제 #1
0
        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(); };
            }
        }
예제 #2
0
        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; };
            }
        }
예제 #3
0
        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();
            };
        }
예제 #4
0
 public static void SetAttachedPopup(DependencyObject obj, BalloonPopup value)
 {
     obj.SetValue(AttachedPopupProperty, value);
 }