简体   繁体   English

.NET Windows控件的样式表

[英]Stylesheets for .NET Windows Controls

I was wondering is there any option of using Stylesheets for .NET Windows controls ? 我想知道是否可以将样式表用于.NET Windows控件?

If not, which is the best way to make the UI look consistent.I need to use VS 2005 to make 如果不是这样,那是使UI看起来一致的最佳方法。我需要使用VS 2005

the changes in the UI. 用户界面中的更改。

Regards 问候

If you want to make your UI consistent and pretty, why don't you give WPF a try? 如果要使UI一致且美观,为什么不试试WPF? You will be able to organize your styles in resource dictionary, then reference to it in all the other projects. 您将能够在资源字典中组织样式,然后在所有其他项目中引用它。

We derive usercontrols from all controls in our system -- all the derived classes do is set the style from a central list of constants defining colours and fonts. 我们从系统中的所有控件派生出用户控件-所有派生类都从定义颜色和字体的常量中央列表中设置样式。 Then we use these controls on our WinForms for a consistent look and feel. 然后,我们在WinForms上使用这些控件以获得一致的外观。 If we want to change the style, we just change the list of constants. 如果要更改样式,只需更改常量列表。 This also allows is to perform UI tricks like setting the background colour of controls to a different colour when they are being edited. 这还允许执行UI技巧,例如在编辑控件时将控件的背景色设置为其他颜色。

Well guess he's talking about WinForms. 好吧,猜猜他在谈论WinForms。 Then you cant use Stylesheets. 然后,您将无法使用样式表。 Havnt coded that much of WinForms. Havnt编码了很多WinForms。 But guess you could have an "Settings/sheet" class that have properties of different style you are using and then set them when creating your controls. 但是,您可能会有一个“设置/工作表”类,该类具有所使用的不同样式的属性,然后在创建控件时进行设置。

您只能在Windows控件中不能在网页中使用样式表。

Even ASP.NET controls, which ultimately render HTML, are notoriously CSS-unfriendly. 甚至最终会呈现HTML的ASP.NET控件也众所周知对CSS不友好。 The reason is that they use tables extensively for layout, and they set a lot of inline style tags which of course do not honor the style sheet. 原因是他们广泛使用表格进行布局,并且设置了许多内联样式标签,这些标签当然不适合样式表。 Some work has been done to create wrappers for these controls, but it was incomplete the last I looked. 已经完成了为这些控件创建包装器的工作,但是最后一次查看还不完整。

It's a shame, but our team will not use the out-of-the box controls most of the time. 很遗憾,但是我们的团队通常不会使用开箱即用的控件。 We've rolled our own and packaged them into an internal library. 我们已经推出了自己的产品并将其打包到一个内部库中。 While the Microsoft controls would have been very useful, they simply don't meet our criteria for clean, accessible, styleable HTML. 尽管Microsoft控件将非常有用,但它们根本不符合我们对于干净,可访问,可样式化HTML的标准。

Microsoft seems, finally, after something like 10 years, to have realized that this is important to a modern development team. 最终,微软似乎在经过了大约十年的时间后才意识到这对现代开发团队很重要。 The control output of ASP.NET MVC is far cleaner and behaves itself quite well with respect to CSS. ASP.NET MVC的控件输出要干净得多,并且相对于CSS而言表现得很好。 Whether they'll eventually revisit the core ASP.NET controls is anyone's guess. 他们最终是否会重新访问ASP.NET核心控件是每个人的猜测。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM