3

ウィンドウは 2 番目のモニターに移動しますが、そこには表示されません。エリアを非表示にするには?

サンプル画像

4

1 に答える 1

1

なぜこれが必要なのかは明らかではありませんが、少し努力すれば達成できます。トリックは、要素を部分的に透明にすることができる OpacityMask プロパティです。大まかなアイデアを提供するためのいくつかのコード:

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
        };
    }
于 2016-04-01T23:05:20.237 に答える