Question

I was reading WPF toolkit's source code, and I found in the Toolkit project, every control was written in two folders named :Implementation and Themes.

Like this: - WatermarkTextBox -- Implementation WatermarkTextBox.cs -- Themes Generic.xaml

By doing this, the control can apply to the Theme by default. By when I delete the Generic.xaml, the Visual Studio get en error to find the Generic.xaml file.

So, I'm confused about this pattern, is this a pattern supported by Visual Studio?

Was it helpful?

Solution

If you create a CustomControl in WPF, you should put your default Style into a file named Generic.xaml. The Framework looks into this file to find default Styles for all CustomControl objects and will give you that error if the file is missing.

You can find a fuller description from the 'Define and Use Shared Resources' section of the Control Authoring Overview page at MSDN.

You can find more exact help with creating a CustomControl from the Try it: Create a custom WPF control page at MSDN.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top