SilverlightExamples.NET

Latest Silverlight Samples, Examples, Demos and Tutorials.

Open File Dialog in Silverlight

clock January 18, 2008 02:40 by author Neo

Silverlight 2.0 Alpha introduced OpenFileDialog control which allows Silverlight applications to open and read *local* files outside Isolated Storage. It's better than the HTML <input> tag which is widely used for uploading files in web page. Well, like HTML <input>, OpenFileDialog could be used to build a file uploader quickly. Both must prompt user to select files. But unlike HTML <input>, OpenFileDialog control could be used to read and process the file data locally in Silverlight application. This is pretty powerful since Silverlight application will not need to upload the files to server for processing. What's more is that OpenFileDialog allows user to select multiple files at once. No need to create multiple instances of OpenFileDialog for that. Let's see some examples:More...

Currently rated 3.7 by 3 people

  • Currently 3.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Fluid Canvas in Silverlight

clock January 17, 2008 06:37 by author Neo

So you wanted the root canvas to scale proportionately to the host element to achieve fluid layout, and you tried setting Width=”100%” or Height=”50%”, but then horror struck because of this parser error: “Invalid attribute value 100% for property Width/Height”.  Ok, to tell you the truth you cannot set “%” to the Width and Height properties because the % is not accepted. Read on for the solution.

The BrowserHost instance has the Resize() event which fires every time the host element is resized and the ActualWidth/ActualHeight properties which tells the dimension of the host element. So, to automatically resize the root canvas, handles the BrowserHost.Resize() event, and from there you can resize the canvas. Let’s sum it up with VB.NET and C# code:More...

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Creating Cool Draggable Window in Silverlight

clock January 13, 2008 22:23 by author Neo

 
 

Silverlight is often dubbed as the would-be better platform for creating Rich Internet Applications. But to date, I’ve seen only applications sitting duck in the browser. Well, I’m not saying that those are not great RIA, but for goodness sake, I want to see something different like a Silverlight application flying around in the browser among HTML elements, or at least a window in Silverlight that could be dragged around. This motivates me to create a proof of concept.

This tutorial basically demonstrates how to create and overlay a draggable window on HTML body in Silverlight 1.1, using managed code and DOM. For simplicity, this sample uses an alpha-blended background PNG image to cast the shadows and make the ‘see-through glass’ effect on the LCD screen.More...

Currently rated 4.6 by 5 people

  • Currently 4.6/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Silverlight Can Go Full Screen and Back

clock January 12, 2008 01:29 by author Neo

So you want your Silverlight video player to play in full screen? No problem! It's pretty easy to go into full screen mode, hiding everything including browser frame, in Silverlight. It's just a line of code:

Application.Host.Content.IsFullScreen = True 

While in full screen mode, user can press ESC key to exit full-screen mode, or your Silverlight application can exit programatically by:

Application.Host.Content.IsFullScreen = False

You can easily toggle between full screen modes by:

VB.NET
Application.Host.Content.IsFullScreen = Not Application.Host.Content.IsFullScreen

C#
Application.Host.Content.IsFullScreen != Application.Host.Content.IsFullScreen;

The Content class exposes two events FullScreenChanged() which fires when the full screen mode is changed, and Resized() event which fires when the host element is resized (not when browser is resized). You can use these events to detect when user gets into and out of full screen mode. It's also worth mentioning that all keyboard events will not fire in full screen mode, only mouse events will. This feature is to protect user from password spoofing and other impersonation attacks.

View Online Demo - Download Source Code (14.34 kb)

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Store and Read Files in Client's Computer Using Isolated Storage

clock January 10, 2008 01:49 by author Neo

Says your application downloads some data files and need to save them locally in the client's computer for subsequent uses. Well, Silverlight in partial-trust mode cannot access client's file system directly, because that would seriously compromise the client's computer. So, Silverlight team devised an ingenious solution by creating a sandboxed virtual file system as known as Isolated Storage. As the name implies, each Silverlight application is given an isolated storage for its own use, up to about 1MB in Silverlight 1.1 Alpha. This opens up a lot of good possibilities like saving user settings, temporary files, form inputs, etc. Without further ado, let's see how to save a text file:More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


How to Get Information About Browser, Web Page and Cookies

clock January 10, 2008 00:45 by author Neo

 

As Silverlight application is hosted in web browser, you might somehow want to get some information about it like browser name, version, platform or user agent. Or you might want to check whether cookies are enabled before reading/writing them. It's pretty easy indeed, because Silverlight exposes the references to the browser and page instances in System.Windows.Browser namespace. They're all there. HtmlPage holds the information of the current web page, and BrowserInformation holds that of the browser. Here's a quick example of how to get the name of the browser:More...

Currently rated 3.7 by 3 people

  • Currently 3.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Execute Code String at Runtime with Silverlight 2.0 DLR

clock January 4, 2008 03:40 by author Neo

Requisites

  • Microsoft Visual Studio 2008
  • Silverlight 1.1 Alpha November Refresh or Newer

Introduction

One of the best additions in Silverlight 2.0 is the implementation of the Common Language Runtime and then the Dynamic Language Runtime, both of which were missing in Silverlight 1.0. Let’s dig a bit deeper in this CLR and DLR thing.

Silverlight 2.0 CLR is a stripped down version of .NET Framework 3.5 featuring the same type system, JIT compiler, garbage collector and a shipload of the same .NET 3.5 namespaces. Silverlight CLR allows .NET code to execute in a sandboxed environment on the client-side. But here’s the problem: Full .NET Framework has the full implementation of System.CodeDom framework which allows .NET code compilation at runtime, but Silverlight CLR strips out 99% of System.CodeDom namespace for security and space concerns. Therefore, you can no longer compile .NET code through the CodeDom in Silverlight. This is when DLR comes to rescue!More...

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Farseer 2D Physics Engine For Silverlight and XNA

clock December 31, 2007 07:30 by author Neo

 

The Farseer Physics Engine is an open-sourced 2D physics engine designed for Microsoft’s XNA and Silverlight platforms. The Farseer Physics Engine focuses on simplicity, useful features, and enabling the creation of fun, dynamic games.

Demos 

You'll find more samples in its SDK download. More...

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Silverlight 8-Ball Game

clock December 30, 2007 21:11 by author Neo

Enjoy the smooth play in this classic two-player 8-Ball Billiards game, thanks to Justin Petersen from Clarity Consulting. Use your mouse to control the pool cue’s direction and power, as well as ball-in-hand Q-Ball placement after a scratch. For developers, you'll get to lean how force, motion and collision detection is done in Silverlight.

Play Online - C# and VB.NET Source Code 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Pop The Balloons!

clock December 30, 2007 21:04 by author Neo

Balloons is a simple game by Pete Brown demonstrating simple animation and dynamic UserControls in full-screen. "I wrote this to amuse my toddler and have managed to amuse a number of developers with it." Pete.

Online Demo - Source Code

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


UserControls as Screens Pattern

clock December 30, 2007 20:48 by author Neo

Pete Brown is showing how to handle multiple screens (like Wizard control) and modal dialog in Silverlight. The pattern illustrated provides a way to simulate windows in what is inherently a non-windowed system: the Silverlight plug-in running inside the browser.

Online Demo - Source Code - Direct Download

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Truck Wars - Silverlight Strategy Game

clock December 30, 2007 20:33 by author Neo

TruckWars is a simple SilverLight real-time-strategy game. For each level, you control various trucks (and other vehicles), and use them to push down all the green buttons. Enemy trucks will try to stop you.

As always, learning Silverlight through games is fun and effective. You get to learn and play at the same time. This is one good game for you to learn how to move objects around with and without obstrucles. The intent is to have a system of interacting objects where the whole is more that the sum of the parts. For example, units can move, attack, push, carry, grow, heal, crush, and even clone. The board includes various blocks - like open space, water, and stop blocks - to allow for different strategy. There is usually several ways to solve each board.

Play Online - Download Source Code

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Free Silverlight Chart Control By Venkata Guddanti

clock December 30, 2007 20:21 by author Neo

Free Silverlight controls are popping up a lot lately, especially WinForms-like and charting controls. Here's another chart conrol The FreeSilverlightChart by Venkata Guddanti. It uses XAML and C# to display charts on the Silverlight platform. The FreeSilverlightChart Control supports quite a lot of chart types including: Verticle Bar, Cylinder Bar, Horizontal Bar, Stacked Vertical Bar, Stacked Horizontal Bar, Pie, Area, Stacked Area, Line, Bar & Line, Area & Line, Bar/Area/Line, XY Line, Scatter Plot, Radar, Radar/Area, Funnel, Circular Gauge, Semi-Circular Gauge. 

Online Demo - Source Code

Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Learn Color And Drawing Through Scribbler Sample

clock December 30, 2007 09:08 by author Neo

Scribbler is a cool sketch pad sample written in Silverlight by Daniel and Pete from Microsoft. Pick a color and start drawing! You can select items and move or delete them. This sample is great for anyone who wants to learn about color and drawing in Silverlight.

Online DemoSource Code

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Silverlight Analog Clock By Microsoft

clock December 30, 2007 08:56 by author Neo

This clock is definitely not for instant use on your website. This sample is intended for showing how to rotate the clock's arm and simulate Timer control from timeline control.

Online DemoC# Source Code - VB.NET Source Code

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Chess In Silverlight By Jonathan Keljo and Gary Linscott

clock December 30, 2007 08:50 by author Neo

Gary and Jonathan from Microsoft coded this chess game which provides a rich game experience with animated pieces and allows mix of human vs computer players. Two different implementations of the computer algorithm are provided in C# and JScript, both of which execute on the client-side.

Chess Demo - Chess Source Code

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Inplay - Audio and Video Player In Silverlight

clock December 30, 2007 08:23 by author Neo

Inplay by Lutz Roeder is an in-page audio and video player. It has play/pause button, timeline position and volume control. Plus, you can easily change the query string to play any online audio or video file or to set auto/manual playback. It is cool, isn't it?

Inplay Demo - Inplay C# Source Code

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Digger Game In Silverlight

clock December 30, 2007 08:14 by author Neo

Digger by Lutz Roeder is Boulderdash game clone in Silverlight 1.1.

Digger Online Demo - Digger C# Source Code

Currently rated 2.0 by 1 people

  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Bubble Factory Silverlight Game

clock December 30, 2007 02:30 by author Neo

This Bubble Factory game was originally created in J2ME (Java). This is basically a port in C# by Vincent Vergonjeanne to run on SilverLight 1.1. It is somehow amazing for the fact that it has been played thousands of time by pure gamers. Play Online

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Nibbles Game in Silverlight 1.1 Alpha

clock December 30, 2007 02:23 by author Neo

SilverNibbles is a port of Nibbles .NET to Silverlight, and Nibbles .NET is based on the Microsoft QBasic Nibbles game. SilverNibbles uses the Silverlight 1.1 Alpha, so that it can make use of C# code. SilverNibbles team have also taken advantage of the graphics capabilities of Silverlight to enhance the appearance slightly. A recent version can be played online

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Search

Calendar

<<  July 2008  >>
SuMoTuWeThFrSa
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

Archive

Tags

Categories


Blogroll

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008

    Sign in