Tag Archives: Silverlight

Create a video player in Silverlight 2 - Part 2

In part 1 we covered setting up a very basic video player. In part 2 we will add

Scrubbing the video
wiring up volume,
and muting.

In future versions I will show how to display a buffer message, skin the controls, and how to work with media that’s not embedded in the xap.

Scrubbing

Add a MouseLeftButtonDown and MouseLeftButtonUp events [...]

Create a video player in Silverlight 2 - Part 1

Creating a video player in Silverlight is pretty simple. The MediaElement does all the heavy lifting, all you need to do is wire up a UI and you have a basic Video player. Here is a tutorial on how to create a simple video player from scratch using Silverlight 2.

Create a Silverlight application
Add [...]

Atlanta Code Camp

My first code camp is over and done with. I got a chance to meet a lot of great people who are as interested and enthusiastic about Silverlight as I am. As promised here are the presentation and the code from my presentation on Saturday.
A couple notes: the presentation is saved as a [...]

Data visualizations

Today I recieved an e-mail to The Best Tools for Visualization.  For the past five years I have worked in a world where there is really only one way to display data, THE GRID.  To be exact, the .NET DataGrid.  This control alone has employed many developers and has allowed them to make a living [...]

Positioning in Silverlight 2

A common mistake in Silverlight is for people to use the Canvas.Left and Canvas.Top property when positioning elements.  In Silverlight 2, there is a push towards a relative positioning model.  This makes the Margin, HorizontalAlignment, and VerticalAlignment very important (for all you CSS people the Margin starts on the Left and goes clockwise).  So, how [...]

Set the source for an image from C#

In Silverlight, there are two ways to set the source for an image.

image.SetValue(Image.SourceProperty,value);
image.Source = new BitmapImage(new Uri(value, UriKind.Absolute));

For the second option you will need to include the following namespace: using System.Windows.Media.Imaging;.

Animation engine for Silverlight

Just added Animations for Width and Height.  Check out the code and the example.  For more information here is the initial post.   I will add more documentation after getting a few more animations in the engine.
Known issues:
After the animation of Width, the width property doesn’t get set.  Same with Height.

Reusing a Storyboard

It is possible to reuse a storyboard.  Make sure to stop the storyboard before you set a new target property.  Thanks Tom for pointing this out.
XAML
    <Canvas x:Name=”LayoutRoot” Background=”White”>
<Button Height=”20″ Width=”120″ Canvas.Left=”0″ Canvas.Top=”0″ Content=”Button” x:Name=”btnTest”/>
<Rectangle x:Name=”Fred” Height=”30″ Width=”30″ Fill=”Aquamarine” Canvas.Top=”50″/>
<Rectangle x:Name=”Wilma” Height=”30″ [...]

Animate Silverlight 2 object from 1 line of code

In a previous post about how to create animations dynamically, I showed how to add StoryBoards from C#. I have extracted this logic into a class called SLAnimator. This allows you to do an animation from one line code, and a nice thing about this approach is it still uses the built in [...]

Consume a JSON object in Silverlight

Here is how to consume a JSON object in Silverlight 2.

Start with a JSON object:
var Person = {
“firstName”: “John”,
“lastName”: “Smith”,
“address”: {
“streetAddress”: “21 2nd Street”,
“city”: “New York”,
“state”: “NY”,
“postalCode”: 10021
}
}
Create an entry point into Silverlight. You will need to add namespace System.Windows.Browser.

Next add C# classes to mirror the JSON object. It’s important to make sure [...]