Silverlight-2.0 – How to make the SilverLight 2.0 button completely transparent?

I have a button that I use on the toolbar with a nice gradient. I want the button to be completely transparent so that only its content and gradient are displayed. When I try, the button appears white Not transparent.

The XAML of my button is:

And the style is:

The best way is to define a new button template. Adding this to the UserControl.Resources tag should work:






















< Storyboard>








x:Name="contentPresenter"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"/>



< /ControlTemplate>

Now your button should be defined as:

If you are using expression blending, you can use it to edit your button template to the content of your mind 🙂 Select your button in the design view-right above the design window will be a gray button named “NewAppointmentButton”. Click it, then “Edit Control”, then “Edit Template”-the button should be a yellow outline .You can now edit visual elements, states and transitions.

Good luck!

I have a button that I use on the toolbar with a beautiful gradient. I want the button to be completely transparent so that only its content and gradient are displayed. When I try, The button appears white instead of transparent.

The XAML of my button is:

And the style is:

< Style x:Key="ToolbarButtonStyle" TargetType="Button">




The best way is to define a new button template. Adding this to the UserControl.Resources tag should work:

< pre>





























x:Name=”contentPresenter”
Content=”{TemplateBinding Content}”
ContentTemplate=”{TemplateBinding ContentTemplate}”
VerticalAlignment=”{TemplateBinding VerticalContentAlignment}”< br /> HorizontalAlignment=”{TemplateBinding HorizontalContentAlignment}”
Margin=”{TemplateBinding Padding}”/>



Now your button should be defined as:

 

If you are using expression blending, you can use it to edit your button template to the content of your mind:) Select your button in the design view-just above the design window will be a file named The gray button of "NewAppointmentButton". Click it, then "Edit Control", then "Edit Template"-the button should be a yellow outline. You can now edit visual elements, states and transitions.

Good luck transport!

Leave a Comment

Your email address will not be published.