











SystemDecorations="None" 无边框
注意:在Avalonia 中,WindowStyle 是WPF的属性,并不使用
正确的属性是 SystemDecorations,它的枚举值包括 None、BorderOnly和Full
当把SystemDecorations 设置为None后,窗口会失去以下由操作系统提供的默认功能
你需要在自定义的标题栏区域或窗口任意位置处理鼠标事件,调用 this.BeginMoveDrag(e)
方法来实现拖拽移动窗口的功能.
PointerPressed="Window_PointerPressed" //在该方法中加入 this.BeginMoveDrag(e) 即可
public void SetPosition()
{
//获取所有屏幕
var screens = this.Screens.All;
if (screens.Count > 1)
{
//选择第二个屏幕作为目标
var targetScreen=screens[1];
//获取该屏幕的工作区
var rect = targetScreen.WorkingArea;
//设置窗口在屏幕左上角显示
this.Position=new PixelPoint(rect.X, rect.Y);
}
}
需要安装包:
| 包名 | 作用 |
|---|---|
| Microsoft.Extensions.Configuration | 提供配置的基础接口和抽象类 |
| Microsoft.Extensions.Configuration.Json | 提供JSON文件读取配置的能力 |
| Microsoft.Extensions.Configuration.Builder | 提供Get、Get(type)、Bind()等扩展方法 |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。