无边框窗口
方式1 样式配置
完全透明
1 | <Window.Styles> |
带阴影
1 | <Window.Styles> |
上面无边框窗口的样式中 设置背景透明色并不是直接使用Background=Transparent
而是用了一个 SolidCorloBrush
设置的Opacity=0
,这么做的原因是直接设置Background=Transparent
发布在Linux(银河麒麟v10) 上,无边框的样式会失效,使用SolidCorloBrush 才可以。
方式2 属性配置
窗口完全透明
1 | SystemDecorations="None" |
窗口带边线和阴影
1 | ExtendClientAreaToDecorationsHint="True" |
这样设置后,窗口会有阴影和边框。
窗口拖动
需要拖动的地方添加PointerPressed
事件
1 | this.PointerPressed += MainWindow_PointerPressed; |
事件
1 | private void MainWindow_PointerPressed(object? sender, Avalonia.Input.PointerPressedEventArgs e) |