c# - 适用于 Windows 10 的 C# 停靠代码栏
问题描述
我正在寻找一种占据窗口顶部 15% 并为用户显示消息(销售电话)的方法,我不希望用户能够调整大小或关闭它。
如果有人最大化另一个应用程序,我不希望它覆盖我们的代码。
解决方案
这只是 WPF 的一个示例:
<Window x:Class="Ticker.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="Ticker"
Topmost="True"
ResizeMode="NoResize"
WindowStyle="None"
WindowStartupLocation="Manual"
Left="0"
Top="0">
<Grid>
</Grid>
根据显示器的高度设置 15% 的高度:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Height = (SystemParameters.PrimaryScreenHeight * 0.15);
this.Width = SystemParameters.PrimaryScreenWidth;
}
}
推荐阅读
- matlab - 读取每个单元格 2 个值作为 (n, j, 2) 矩阵的电子表格
- go - 如何在没有第三方 pkg 的情况下为文本设置颜色
- flyway - 如何通过 micronaut 应用程序配置设置飞行路径占位符?
- django - 我需要帮助为我的 SQLite 数据库中的项目创建自定义计数器
- java - ByteBuf 发布场景
- php - 是否可以为特定会话设置 $_SESSION 变量?
- vue.js - 测试 Vue 组件:无法挂载组件:未定义模板或渲染函数
- pandas - 合并以仅替换 nan 值
- python - 我在理解这个 python 代码时遇到了问题
- javascript - 如何在 React 中使用 reduce 和 promise.all 显示多组数据