Wednesday, March 24, 2010

Cochin Twestival 2010

Facebook For Dummies

We are holding Cochin Twestival 2010 on 25th March, 2010 - 5 to 8 PM! For the Tweeple in Cochin, Cochin Twestival is the can't-miss event.


RSVP for Cochin Twestival



For those of you who don’t know what a Twestival is...


It is a mega tweet-up with lots of things added. In short, it is a Twitter Festival. Twitter Festivals or Twestivals happen all around the globe once a year. There are basically two types of Twestivals: Twestival Global & Twestival Local. Twestival Global is one day, one cause all around the world and Twestival Local takes place over a weekend where cities are encouraged to support a local cause. Both versions have international momentum, but the real power of Twestival is when everything comes together on one day, giving focus to an important cause, the cause being different every year.
Cochin Twestival



Venue



Cochin Twestival 2010 will be held at Somewhere Else Cafe. A map to the location is available at Twitter Kerala


Registration



You can register for the event in the Facebook Event Page.

Monday, March 22, 2010

Silverlight Dynamically Creating Controls and Attaching Event Handlers

Pro Silverlight 4 in C#Dynamically creating controls in Silverlight is a breeze.
I am using Visual Studio 2010 Release Candidate.
I am starting a Silverlight Application Project.














I am selecting Asp .Net Web Project as new Web Project Typer.
















As mentioned in the previous blog VS 2010 comes with excellent tool support for Silverlight.

I am adding a Stack Panel (stp1)to hold the dynamically created controls and a TextBlock to display the message based on the control selected.















Going to the load event of Main Page I am dynamically creating Buttons.


List<string> lstr = new List<string> { "Shalvin", "Praseed Pai" };

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
Button btn;
foreach (string str in lstr)
{
btn = new Button();
btn.Content = str;
btn.Tag = str;
btn.Click += new RoutedEventHandler(btn_Click);
stp1.Children.Add(btn);
}
}

Notice I have only one event Handler for the whole set of controls.
I am going to have different functionlity for different buttons by identifying the tag property of Button.

private void btn_Click(object sender, RoutedEventArgs e)
{
Button btn = sender as Button;
string txtTag = btn.Tag.ToString();
tblMessage.Text = txtTag;
}