1. 程式人生 > >C# the SystemParameters, “type or namespace does not exist”

C# the SystemParameters, “type or namespace does not exist”

ctu forms log bound question gpo sharp color project

the SystemParameters, “type or namespace does not exist” 解決方法

* add a project reference

  • In Solution Explorer, expand the project, right click on References and click Add Reference.
  • Now click Browse on the bottom, find the DLL you are trying to use. In this case it should be included under Assemblies
    - Framework
    .
    Click on Framework on the left menu.
  • Find PresentationFramework on the right. Make sure you Check mark it
  • Click OK.

Now you have the reference, go back to your code and it should work. Again, make sure you create a WPF Project not WinForms...

using System.Windows.Forms in your code.

REF:

https://stackoverflow.com/questions/22026116/c-sharp-cant-use-the-systemparameters-type-or-namespace-does-not-exist

其他:

WinForm

//獲取PC屏幕的寬
int width = Screen.PrimaryScreen.Bounds.Width;
//獲取PC屏幕的高
int height = Screen.PrimaryScreen.Bounds.Height;

Screen.PrimaryScreen.WorkingArea.Height;

Screen.PrimaryScreen.WorkingArea.Width;

WPF

SystemParameters.WorkArea;//除任務欄外工作區大小
SystemParameters.PrimaryScreenWidth;//屏幕寬
SystemParameters.PrimaryScreenHeight;//屏幕高

double dWidth2 = ActualWidth; //獲取此元素的呈現寬度。若此元素時全屏的,則可以獲得屏幕大小

double dHeight2 = ActualHeight; //獲取此元素的呈現高度。

C# the SystemParameters, “type or namespace does not exist”