Wednesday, February 4, 2009

Little tidbits about Silverlight 2.0

Hii, I am Shrey Chouhan. This is my first blog.

Lets share my coding experience with you.

If you are developing a page in Silverlight 2.0 and want to change Grid Background color dynamically then follow these steps.

In your XAML page, first create GRID and named it "gridColor".

And then write these lines in code behind page

LinearGradientBrush lb = new LinearGradientBrush();
GradientStop gs = new GradientStop();
gs.Color = Colors.Brown; // Set the color
lb.GradientStops.Add(gs);
gridColor.SetValue(BackgroundProperty, lb);



And finally you do that....

Similary, you can change background (color) of any other control also.

Thanks...

Shrey Chouhan

No comments:

Post a Comment