views:

134

answers:

2

I'm interested in customizing a 3rd party control, such as Telerik's RadGridView, as a standalone control, for example adding New Row and Delete Row buttons above the grid, yet still supporting XAML manipulation of the internals of the control by the window upon which my control exists (i.e. for the window to add its own style to a column of the grid).

Is there a way to add the buttons, etc. with templates? Styles?

My current "solution" is to inherit from the RadGridView, but I'm stuck on how to add the features I need.

Thanks!

+1  A: 

I would go the custom UserControl route instead of inheritance route. Styling and theming work strangely when you're dealing w/sub-classes. Unless you're planning on duplicating and modifying Telerik's ControlTemplates and DataTemplates, it can get pretty hairy.

micahtan
+1  A: 

My suggestion is to use composition over inheritance.

You can create your own control (UserControl should do the work). Then you can define the layout (may be in Grid panel): buttons on the top, RadGridView bellow them, etc. For custom column styling you can use DynamicResource trick. Set the styles of the columns you want to modified with DynamicResource. This way when the control is added to the logical(visual) tree; WPF will walk up the control tree and find appropriate resource. This way in each window/page resources you can define the different resource.

Another idea that come to my mind is that you can extract the buttons as a separate control. The only reference that they will need will be RadGridView and you can use binding with element name to provide it.

ligaz