views:

57

answers:

1

Hello,

I have a question regarding template parts. I want to create a control that inherits from ChildWindow, but I don't want it to have a border, OK/Close buttons, etc.

Is it an acceptable practice to remove the template parts that I don't want? I have created a copy of the ChildWindow template in Blend and removed the template parts, and it works fine - I just want to make sure that that won't cause any problems down the road.

Thanks, Charles

+2  A: 

If you read some of the custom control development documentation on MSDN it specifically mentions that developers should anticipate that template parts may not exist and code for it, so I think you're Ok there. Personally, when I need to remove template parts I prefer to leave them in the Xaml but set Visibility = Collapsed for something like a button or BorderWidth = 0 for something like a Border. Personal preference I suppose.

James Cadd
Thanks for the suggestion. I just recently read that Microsoft advises developers to make their customer controls such that they do not throw exceptions when control parts are missing - so it sounds like you're right about it being optional. I'll probably just collapse the parts I don't need, just in case.
Charles
I second your comment, JC. Template parts may never be there, and that's vital.
Jeff Wilcox

related questions