private void AttachVisibilityHandler(WindowCommandsItem container, UIElement item) { if (container != null) { // hide the container, if there is no UIElement if (null == item) { container.Visibility = Visibility.Collapsed; return; } container.Visibility = item.Visibility; var isVisibilityNotifier = new PropertyChangeNotifier(item, UIElement.VisibilityProperty); isVisibilityNotifier.ValueChanged += VisibilityPropertyChanged; container.VisibilityPropertyChangeNotifier = isVisibilityNotifier; } }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); hwndSource = (HwndSource) PresentationSource.FromVisual(this); if (hwndSource == null) return; var ws = hwndSource.Handle.GetWindowLong(); var wsex = hwndSource.Handle.GetWindowLongEx(); //ws |= WS.POPUP; wsex ^= WSEX.APPWINDOW; wsex |= WSEX.NOACTIVATE; if (Owner.ResizeMode == ResizeMode.NoResize || Owner.ResizeMode == ResizeMode.CanMinimize) { wsex |= WSEX.TRANSPARENT; } hwndSource.Handle.SetWindowLong(ws); hwndSource.Handle.SetWindowLongEx(wsex); hwndSource.AddHook(WndProc); handle = hwndSource.Handle; ownerHandle = new WindowInteropHelper(Owner).Handle; resizeModeChangeNotifier = new PropertyChangeNotifier(Owner, ResizeModeProperty); resizeModeChangeNotifier.ValueChanged += ResizeModeChanged; }
private void AttachHandlers(Flyout flyout) { var isOpenNotifier = new PropertyChangeNotifier(flyout, Flyout.IsOpenProperty); isOpenNotifier.ValueChanged += FlyoutStatusChanged; flyout.IsOpenPropertyChangeNotifier = isOpenNotifier; var themeNotifier = new PropertyChangeNotifier(flyout, Flyout.ThemeProperty); themeNotifier.ValueChanged += FlyoutStatusChanged; flyout.ThemePropertyChangeNotifier = themeNotifier; }