It will be helpful as we explore custom controls to have a common starting project. You may remember from my posting on the 12th that I laid out a structure with three projects in one solution, with 5 important files.
- In the ClassLibrary, customcontrol.cs which defines the logic and methods as well as the attributes of the custom control. The attributes define the contract, and are what make the control skinnable with the assistance of tools like Blend
- Also in the ClassLibrary is a file that must be named generic.xaml that defines the default look for your custom control (in xaml).
- In your application there are three files (as usual) that do the heavy lifting: Page.xaml, Page.xaml.cs and App.xaml. They do their normal jobs. That is: Page.xaml makes an instance of the control and may or may not include a Template statement asking for a Template in Page.xaml or (more likely) in App.xaml to override the default look and feel
- Page.xaml.cs contains the logic of the application (not of the control) just as it always does
- App.xaml may have a template for your new Custom control just as it may have a template for button or checkbox.
I’ve created a starter application with corresponding files and placed it here The starter application just lays out the structure of the program and will be used for three inter-related purposes
1. An intensive tutorial (expected publication date approximately 10/13
2. A set of video I’ll be developing in the next week or two
3. Blog entries exploring what I hope will be interesting topics in depth
Following the suggestions received here, the tutorial should be pretty intensive, while the blog and videos will assume a more intermediate level of knowledge. If this topic (templatable custom controls) is of interest, you’ll want to start by reviewing some or all of these:
- Intro To Custom Controls
- Digging into Custom Controls
- Dependency Properties – Background
More Skinnable Custom Controls – Change to generic.xaml