I have a button that I am using on a toolbar that has a nice gradient. I want the button to be completely transparent so that just its contents show against the gradient. When I try, the button appears white rather than being transparent.
The XAML for my button is:
<Button Name='NewAppointmentButton' Style='{StaticResource ToolbarButtonStyle}'> <TextBlock>X</TextBlock> </Button>
and the style is:
<Style x:Key='ToolbarButtonStyle' TargetType='Button'> <Setter Property='Background' Value='Transparent'/> <Setter Property='BorderThickness' Value='0'/> <Setter Property='Height' Value='24'/> <Setter Property='Width' Value='24'/> </Style>
The best way is to define a new button template. Adding this to your UserControl.Resources tag should work:
Now your button should be defined as:
If you’re using expression blend you can use it to edit your button template to your heart’s content 🙂 Select your button in design view – just above the design window will be a grey button called ‘NewAppointmentButton’. Click on it, then ‘Edit control parts’ then ‘Edit template’ – the button should get a yellow outline. You can now edit the visual elements and states and transitions.
Good luck!