我正在尝试使用以下代码更改一组以编程方式生成的列表框:
newListBox.Margin = new Thickness(0, 0, 0, 0);
然而,这给了我错误:
the type or namespace Thickness could not be found
我尝试添加using System.Windows
命名空间,但我仍然遇到同样的错误。有人可以帮忙吗?
答案 0 :(得分:4)
System.Windows.Thickness
是Presentation Framework的一部分。如果您不使用WPF或Silverlight,请尝试引用 PresentationFramework.dll 以访问Thickness
结构。
但是我担心在这种情况下你的ListBox.Margin
不会接受Thickness
类型的对象。如果您正在使用WinForms,请尝试System.Windows.Forms.Padding
。
答案 1 :(得分:2)
我相信你正在寻找Padding
。见Control.Margin
newListBox.Margin = new Padding(0, 0, 0, 0);
答案 2 :(得分:1)
Intellisense是你的朋友。如您所见,您想要使用Padding对象。