WPF無邊框拖動 全屏 縮放

2021-08-08 14:49:30 字數 1293 閱讀 5739

先看效果

無邊框設定windowstyle=「none」,視窗無關閉及縮放按鈕,但還有黑邊;設定allowstransparency=「true」,黑邊沒有了。

全屏,遮住工作列

this.windowstate = system.windows.windowstate.normal;

this.windowstyle = system.windows.windowstyle.none;

this.resizemode = system.windows.resizemode.noresize;

= true;

//設定全屏

this.left = 0.0;

this.top = 0.0;

this.width = system.windows.systemparameters.primaryscreenwidth;

this.height = system.windows.systemparameters.primaryscreenheight;

拖動

//xaml

mousemove="move_mousemove"

//cs

private void move_mousemove(object sender, mouseeventargs e)

}

另一種拖動方式

不能拖動太快

system.drawing.point mousecursor_point;

system.drawing.point mousecursor_point_aux;

double mtop = 0;

double mleft = 0;

private void button_mousemove(object sender, mouseeventargs e)

,)");

}else

}else

}

或者,這種需要慢點拖,否則會有問題

system.drawing.point mousecursor_point;

system.drawing.point mousecursor_point_aux;

private void button_mousemove(object sender, mouseeventargs e)

mousecursor_point = system.windows.forms.cursor.position;

}

WPF無邊框視窗滑鼠拖動縮放大小

通常,我們會 通過allowstransparency true windowstyle none 這兩個屬性將wpf視窗的邊框去掉,由於邊框沒了,我們就不能通過滑鼠指標懸停在某一邊上拖動改變視窗的大小,此時若要能調整視窗大小,官方倒也提供了個屬性 resizemode canresizewithg...

c 無邊框拖動

static class safenativemethods protected override void onmousedown mousebuttoneventargs e 拖動protected override void wndproc ref message m return case ...

拖動無邊框窗體

frm main.cs 1 using system 2using system.collections.generic 3using system.componentmodel 4using system.data 5using system.drawing 6using system.linq ...