好吧,试试吧
WindowStyle="none"
Run Code Online (Sandbox Code Playgroud)
像这样:
<Window x:Class="Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" WindowStyle="None"
MinHeight="350" MaxHeight="350" MinWidth="525" MaxWidth="525">
<Grid>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
编辑:
它看起来有点愚蠢,但这种方式(Min-和MaxHeight/Width在相同的大小)你可以防止窗口调整大小
这是另一种方法.要删除Max- /最小化,您需要更改ResizeMode此类似的内容
<Window x:Class="MyWpfApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="" Height="350" Width="525" ResizeMode="NoResize">
<Grid>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
之后你可以通过添加这个删除关闭按钮(在这里阅读更多)
private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x80000;
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
public MainWindow()
{
SourceInitialized += Window_SourceInitialized;
}
void Window_SourceInitialized(object sender, EventArgs e)
{
var hwnd = new WindowInteropHelper(this).Handle;
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10243 次 |
| 最近记录: |