3

The window goes to a second monitor, but there should not be visible. How to hide the area?

Example image

StepUp
  • 36,391
  • 15
  • 88
  • 148

1 Answers1

1

It's not clear why you need this, but it can be achieved with some effort. The trick is OpacityMask property, which allows to make elements partially transparent. Some code to give you rough idea:

public MainWindow() {
        InitializeComponent();            
        this.WindowStyle = WindowStyle.None; // required for AllowsTransparency
        this.AllowsTransparency = true; // allow window to be transparent            
        var group = new DrawingGroup();
        // make first 100x1000 part of window transparent
        group.Children.Add(new GeometryDrawing() {Brush = Brushes.Transparent, Geometry = new RectangleGeometry(new Rect(0, 0, 100, 1000))});
        // make the rest part white or whatever color you use
        group.Children.Add(new GeometryDrawing() {Brush = Brushes.White, Geometry = new RectangleGeometry(new Rect(100, 0, 1000, 1000))});
        this.OpacityMask = new DrawingBrush(group) {
            Stretch = Stretch.None,
            AlignmentX = AlignmentX.Left,
            AlignmentY = AlignmentY.Top
        };
    }
Evk
  • 98,527
  • 8
  • 141
  • 191
  • Thank you. I am creating a menu information that pops up when click on the icon in the system tray as Action Center in Windows 10. Your method is right for me, but the problem arose in the blur on the background of window – user3328301 Apr 01 '16 at 23:38