public void RegisterPopup (Popup popup)
		{
			var width = popup.WidthRequest ?? 100;
			var height = popup.HeightRequest ?? 50;

			var surface = new GtkSurface (popup, 0, 0, width, height, Gtk.WindowType.Popup);
			popup.Opened += (sender, e) =>
			{
				var p = popup.PlacementTarget.PointToScreen (new Point (0, popup.PlacementTarget.DesiredSize.Height));
				surface.Move ((int)(p.X + popup.HorizontalOffset), (int)(p.Y + popup.VerticalOffset));

				surface.ShowSurface ();
			};
			popup.Closed += (sender, e) => surface.Hide ();
		}
Пример #2
0
		private static UIElement MenuItemTemplate (UIElement element)
		{
			var header = new ContentControl ();
			BindingOperations.SetBinding (element.GetProperty ("Header"), header.GetProperty ("Content"));

			var popup = new Popup ()
			{
				PlacementTarget = element,
				VerticalOffset = 6,
				HorizontalOffset = -5,
			};

			BindingOperations.SetBinding (element.GetProperty ("ItemsPanel"), popup.GetProperty ("Child"));
			BindingOperations.SetBinding (element.GetProperty ("IsSubmenuOpen"), popup.GetProperty ("IsOpen"));

			return header;
		}
		public void RegisterPopup (Popup popup)
		{
			aplication.RegisterPopup (popup);
		}