1

are there good books on developing custom controls for silverlight?

What I want is to create a grid-control that can also act as TreeList-control. Can you tell me what is a good base-class for such a control?

And another question: If I develop a control in Silverlight, how can I reuse my code for the same controls as WPF?

Do have to duplicate the code? I hope not...

Bye Matthias

codegod
  • 11
  • 4
  • Hybrid of the DataGrid and the TreeView is one of the most frequent questions about WPF controls: http://stackoverflow.com/questions/4293739/datagrid-that-also-supports-a-tree-view. But I haven't seen a good answer yet, and it will be even more difficult with Silverlight. – vortexwolf May 02 '11 at 12:41

1 Answers1

0

What I want is to create a grid-control that can also act as TreeList-control. Can you tell me what is a good base-class for such a control?

Basically, it depends on several factor and you have more options. In my opinion, I would choose to go with Panel, incase if I need more control during layout and arrange process.

Or else, you could simply extend from the ItemsControl and write you own control. But if you are planning for much bigger implementation, then I would highly suggest you to read the implementation of GridControl available in the WPF Toolkit.

Tree List Control On Code Project

And another question: If I develop a control in Silverlight, how can I reuse my code for the same controls as WPF?

Sharing Code Between WPF and Silverlight From MSDN

Karthik Mahalingam
  • 1,071
  • 8
  • 10
  • 1
    I think that the implementation of the control in codeproject is not flexible enough. I think I have to derive from panel, cause I need full control. And if I derive from Panel, do I have to render the control by myself? – codegod May 04 '11 at 05:20
  • @codegod, yep. Basically, panel does not how to layout or render it's children. So you have to override both ArrangeOverride() and MeasureOverride() to render your custom control. IMO, I would try to get this TreeList control implemented by modifying control templates of any of the existing WPF ItemsControl. But if you choose to go with Panel approach then it would typically take 1 month to get the control implemented. There are lot of stuffs, you need to take care for ex: virtualization. BTW, what is missing with the code project control or what kind of flexibility you are looking for ? – Karthik Mahalingam May 04 '11 at 10:11
  • 1
    Well, the codeproject-control is derived from ListView and I have two problems with this approach: I don't know how fast the ListView is, especially for large amounts of data. Does ListView only render the items that are currently visible? Next problem is that I want to have the possibility to display the data grouped (like in outlook) or as card-view. This means I need total flexibility for layout. – codegod May 04 '11 at 10:56