我使用Visual Studio 2013 Professional,C#, 我的代码中有这些用法和那一行。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
this.Width = System.Windows.SystemParameters.PrimaryScreenWidth;
然而它有一个类似“类型或命名空间名称'的错误'SystemParameters'在命名空间'System.Windows'中不存在(你是否缺少程序集引用?)”
我真的不明白最新情况,我是否应该添加更多内容以使用系统管理员?
答案 0 :(得分:4)
System.Windows.SystemParameters
类在PresentationFramework.dll
程序集中定义,它是WPF UI Framework的一部分。
从您的问题中不清楚您正在定位哪个UI框架,但由于您的代码中存在using System.Windows.Forms
,我认为它是winforms。
答案 1 :(得分:1)
<强>更新强>
要获取表单的ScreenWidth和ScreenHeight,只需执行以下操作:
var height = this.Size.Height; //Gets the current Height of the Form.
var width = this.Size.Width; //Gets the current Width of the Form.
this.Size = new Size(1000, 200); // Sets new Width/Height for form.
您需要引用DLL。我还有一种感觉,当你真正想要winforms
时,你创建了一个WPF Project
项目;您并且正在尝试使用WPF组件...
PresentationFramework(presentationframework.dll)实现了 最终用户表现特征,包括布局,时间依赖, 基于故事板的动画和数据绑定。
添加项目参考
References
,然后点击Add Reference
。Assemblies - Framework
下。点击左侧菜单中的Framework
。PresentationFramework
。确保勾选标记 现在你有了参考,回到你的代码,它应该工作。同样,请务必创建WPF Project
而不是WinForms
...
答案 2 :(得分:0)
您需要添加对PresentationFramework.dll的引用
答案 3 :(得分:0)