Silverlight Expand Button Size On Mouse Click in VB.NET
In this article you will learn how to expend the Button size on mouse click in Silverlight.
The below example shows you that, when you click on the button at that time button size will increase.
Example of Expended Button
MainPage.xaml.vb Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace SilverlightApplication5
{
public partial class MainPage : UserControl
{
const double minSize = 15;
const double maxSize = 50;
Button b;
public MainPage()
{
InitializeComponent();
ExpendedButton();
}
public void ExpendedButton()
{
this.Tag = "ExpendedButton";
b = new Button();
b.Content = "Expanding Button";
b.FontSize = minSize;
b.HorizontalAlignment =HorizontalAlignment.Center;
b.VerticalAlignment =VerticalAlignment.Center;
b.Click += afterClick;
Content = b;
}
void afterClick(object sender, RoutedEventArgs args)
{
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(0.2);
timer.Tick += starttimer;
timer.Start();
}
void starttimer(object sender, EventArgs args)
{
b.FontSize += 3;
if (b.FontSize >= maxSize)
{
b.FontSize = minSize;
(sender as DispatcherTimer).Stop();
}
}
}
}
Output Window
Button before mouse click
Button after mouse click
Conclusion
Hope you will learn through this article how to Expend the Button size on mouse click in Silverlight.
The below example shows you that, when you click on the button at that time button size will increase