Change Background of Silverlight Button
I have com accross some areas when working with setting. silverlight button background. Thought of sharing with all.
1. Change Background Color
when you try to change the background color of a silverlight button as below it will show the button as below with the gradient effect.
<Button Content="Button" Height="31" HorizontalAlignment="Left" Background="DarkGreen" Name="btn" VerticalAlignment="Top" Width="142" Margin="30,60,0,0" />
if you want to change the background color without the gradient effect below code is the solution.
<Button Content="Button" Height="31" HorizontalAlignment="Left" Background="DarkGreen" Name="btn" VerticalAlignment="Top" Width="142" Margin="30,60,0,0" >
<Button.Template>
<ControlTemplate TargetType="Button">
<Border x:Name="Border" Background="DarkGreen" >
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
</ControlTemplate>
</Button.Template>
</Button>
2. Change Background Image
if you need to set an image as the button content then can use the following code.
<Button Name="btnNext" BorderThickness="0" >
<Image Source="Capture.png" Height="64" Width="190" />
</Button>
Happy Coding !!!
Comments
Post a Comment