wpf - How to change the look and feel of ASP.NET server controls?

问题描述:

Is it possible to change the default template of each ASP.NET server control? In WPF and Silverlight, each control is supposed to be lookless, so the developer can provide a user-defined control template to change how the control looks. If, for example, I want to use an outer and inner square/rectangle other than an outer and inner circle in a RadioButton, how do I accomplish that?

网友答案:

Don't have much experience with ASP but we used to work with Prado a lot (a PHP framework that behaves much like ASP .NET).

I would say the easiest thing to do is assign a CSS class to the component, which you should be able to do to any ASP .NET component and then simply use CSS to style the component.

At the end of the day, its all spat out to the browser as HTML anyway, so there's no real reason why you couldn't style it using CSS.

I recommend you don't use the standard CSS classes, unless you want all instances of a particular component to the look the same for your application.

We write a lot of Ajax apps and this is what we do.

网友答案:

ASP.NET has support for Themes and Skins. You can use a combination of skins and CSS (packaged up into a theme for convenience) to apply some styles to your controls. However, different browsers on different operating systems may render various controls slightly differently (for example take a look at how radio buttons are rendered). I'm not sure how much control you'll have over that behavior.