views:

2173

answers:

4

I'm looking into creating custom controls for WPF and I've found some reasonably useful blogs and such that vaguely go into enough detail but I'm still struggling a bit.

Basically, what I'm trying to create is something akin to the infamous 'Coda Slider' but i just don't know enough to get started properly. Can anyone either point me in the direction of someone/somewhere to give me the low-down on creating custom ItemControls or provide me with the basic information like what ItemsControl members i need to override?

All help would be graciously received.

+2  A: 

Building a custom WPF control is nothing more than writing a class and inheriting the class from a base class that is provided in WPF.

How to Create a Custom WPF Control

TStamper
That makes it sound very simple, and whilst the statement is correct in and of itself, you must know which type to derive from and then which methods to override in order to have the desired behaviour. You can get a LOT of mileage out of the basic controls provided in WPF simply through templating and styling.
Drew Noakes
+2  A: 

I think the first question you have to ask yourself is why you feel you need a custom control? Are you exposing new behavior? If not, then Styling and Templating are where you need to focus.

If you really plan to add some new feature, like exposing a new property or creating something really different, then I'm sure a little Google searching will find what you need. For example, here is an excellent article by Sacha Barber where he shows inheriting from an existing control.

I'm not trying to be flip: perhaps you could be more specific about the problems or questions you are having.

Joel Cochran
+1  A: 

Correct me if I'm wrong, but just looking at the "coda slider", it looks to basically be a TabControl with animations.

I'm pretty sure you would be better served by using a custom templating of the TabControl using animations and/or attached properties.

If that is the case, tell us and we can certainly point you in the right direction. Custom controls are rarely a necessity with WPF.

Denis Troller
+1  A: 

I had seen this same functionality in an open source WPF project called "WittyTwitter". When I looked through the code, they were using something called the ZapScroller in Kevin Moore's "WPF Bag-o-Tricks" library. He was a PM for WPF at Microsoft. Have a look here:

http://work.j832.com/2008/03/bag-o-tricks-march-edition.html

Rich
You know what, that's pretty much perfect. Cheers dude.
Stimul8d