I followed ChrisF
here and write a simple demo.
...open your project in Expression Blend, select the button and then right click and select "Edit Template > Edit a Copy..". This copies the existing template into one you can modify. It's easier if you create it in a resource dictionary.
And I can see the behind-the-screen template of the button as below screenshot (The ButtonChrome in Resource).
I want to remove the white-gradient border of the ButtonChrome AND keep everything else of the button's UI remain as-is. How can I do that?
ps. To make the problem simple I use the ButtonChrome as a normal control on my view. I browse the properties but still got NO idea where to remove the "white" border.
(The ButtonChrome in-use)
(The ButtonChrome in Resource)
You should not try to customize ButtonChrome. *Chrome classes are theme-specific, i.e. they contain implementation of a specific windows theme and you cannot override it. Look at the declaration of the "Microsoft_Windows_Themes" namespace in your resource dictionary - it probably contains something like PresentationFramework.Aero...
What you should do in your custom templates is use usual Border instead of ButtonChrome and define triggers that will change its background, etc. when the button is pressed or hovered.
Here is an example:
I don't think there's an easy way to get rid of that White Border. The actual routine being called is DrawInnerBorder and its called from within OnRender in ButtonChrome.
As we can see, there is no property to disable this. You can verify it by setting
IsEnabled="False"
andRoundCorners="False"
on the ButtonChrome or by setting Width or Height to something like 3.99 and the "White Border" goes away.Update
To disable the inner border of ButtonChrome you could create your own ButtonChrome which adds this property. Unfortunately ButtonChrome is sealed so we can't inherit from it. I tried to copy the whole class and add the Property DisableInnerBorder and it seems to be working. You can use it like this
Other than that it works just like the regular ButtonChrome and you can also add other Properties etc. that you might want. There might be drawbacks to this method that I haven't thought of, but for a small test it worked just fine.
Apperently 937 lines of code was too much to post on SO :) I uploaded MyButtonChrome.cs here: http://www.mediafire.com/?wnra4qj4qt07wn6
if you want to just avoid the WhiteBorder you have to just change the BorderBrush=Transparent
If you want to modify some other things you have to create your own ControlTemplate
please this link
http://mark-dot-net.blogspot.com/2007/07/creating-custom-wpf-button-template-in.html
here they have different button templates
Asfter discussing with Meleak for a while, finally I got the final solution for my question! Thank you Meleak!
You can download the solution source codes here.
An option is also to use an other library like telerik or xceed (also available for free commercial-use). In my solution I created a class an derived it from Xceed.Wpf.Toolkit.Chromes.ButtonChrome (the Microsoft ButtonChrome is sealed). In my ResourceDictionary I implemented an style for Combobox, created by Blend for VS. In the ControlTemplate for the ToggleButton I have implemented following code:
Here you can see only the most impertand stuf. Your DownArrowGeometry and so on, you know to do. I hope this can help someone ;-)
I realize this is an old thread, but I found it when I was trying to do the same thing and didn't find any great solutions. I thought I'd post what I came up with in case it helps anybody else.
What I wanted was flat buttons that used the normal chrome when moused over. The best way I could find to do this was to cheat and use two ContentPresenters inside a Grid with two rows. One content presenter is inside the normal ButtonChrome and one is inside a Border. Only one grid row is shown at a time and the setter in the IsMouseOver trigger determines which one is shown.