

Here you can see I have set up a simple border which gives my button rounded corners, a single pixel gray border, and uses the fill from the control's Background property. So a template allows us to completely control what visual elements constitute our control.Īgain this goes in Page.Resources. But I want complete control - including the appearance in mouse over, mouse down and disabled situations. We would already be finished if I just wanted the normal appearance of my button to be changed. So I need another style in my Page.Resources section: The only complicated bit is that I am overriding the focus rectangle drawing, as I want a smaller rectangle than the one that gets drawn by default. This is all fairly straightforward stuff - I am just setting the font and background gradient. We will put this in the Page.Resources section of our XAML file.

The first thing to do is to create a Style which sets the properties of the Button that we want to customize.

In particular we will look at being able to have complete control over all the visual states, including disabled, mouse over, mouse down and even the appearance of the focus rectangle. In this post I will demonstrate how to create a custom template for a WPF button using XAML.
