Idov
Idov

Reputation: 5124

Skinning C# controls?


Is there a way to make a new skin to a C# control?
for example, I want to have a listview with the same functionality of the default one but with a completely different look.
thanks :)

Upvotes: 0

Views: 1935

Answers (5)

JonWillis
JonWillis

Reputation: 3147

I've gone down this route before, and its not pretty. In the end I didnt reskin the control. We had an issue with a WinForms treeview. Thats a tale for another time.

In WinForms, then yes you make a derived version for the control you want to edit. And overright the OnPaint and relevant Paint methods. For the treeview this was a nightmare so didn't do it in the end. Unless your experienced in drawing controls from scratch I would not consider this option.

If your in WPF, its much easier the controls are all made of visual elements, and is much easier to change them. WPF has fewer controls and relying on the developer editing them for there own need. Personally I want more basic WPF controls like WinForms, but again thats another tale.

The other 2 options are, start a brand new control from scratch, or find the look of a control you like online and purchase it. Many websites sell custom made .net controls.

Upvotes: 1

dst
dst

Reputation: 27

Still, if you are using Windows.Forms and wish to change the look of your controls than it will be a bit tougher.

You will have to create a derived class from the control and override the OnPaint and OnPaintBackground events and implement your own code.

Upvotes: 2

Sören
Sören

Reputation: 2731

As Femaref says, there are many possibilities in WPF, but it is rather difficult in WinForms.

If you want to go a bit further than the page linked by him does (it only covers styles), you may be interested in the point "templates and styles" in the sidebar of the same page: templates and styles and in the templates part there: templates. With templates, u can do most of the things you cannot do with styles. A quite basic example (that u will find in almost every tutorial about templates) is an elliptic button. Additionally, you can also redefine other things, e.g. the mouse over and mouse click appearence by using triggers.

Hope that helps ;)

Upvotes: 1

Femaref
Femaref

Reputation: 61437

Depends on your library.

Win Forms: tedious and really hard to do. You will have no hair on your head after you are finished with styling one single control.

Wpf: Wpf is build for exactly that (and of course, many other amazing things). This page might help you alot.

If you want to skin your application entirely, I'd advise you to learn and use WPF. I did it is as well and it is amazing, not just the customizability, but everything in general. It is a great platform, but as it needs DirectX and more resources, it is not as portable.

Upvotes: 4

escargot agile
escargot agile

Reputation: 22379

Yes, with WPF everything is possible. But if you're used to Windows Forms only, keep in mind that WPF is a new technology with new concepts that take some time to learn.

Upvotes: 1

Related Questions