Blog

posts tagged with csharp

Simple ReportDocument for Silverlight 4

0 Comments
By Fons Sonnemans, 25-nov-2009

I have written an Simple Report Library for Windows Forms applications a few years ago. The new Printing API makes it possible to create a similar solution for Silverlight 4.

You create a report by instantiating a new ReportDocument object. You can set the Title and the SubTitle. Next you add Paragraphs (FrameworkElements) to the report. Finally you Print the report.

ReportDocument r = newReportDocument() {

    Title = "Test Title",

    SubTitle = "Test SubTitle",

};


for (int i = 0; i < 40; i++) {


    var tb = newTextBlock() {

        Text = "Test text " + i,

        FontSize = i + 10,

    };


    r.Paragraphs.Add(tb);

}


r.Print();

This prints the following Test Title.pdf if you print it to a PDF writer.

Test Title.pdf

READ MORE

SilverlightXP 2.0 release

0 Comments
By Fons Sonnemans, 24-nov-2009

Visit SilverlightXP

SilverlightXP is a web application where Silverlight Developers and Designers can post links to controls, resources and other interesting information about Microsoft Silverlight.

READ MORE

Silverlight Flip Clock

0 Comments
By Fons Sonnemans, 04-nov-2009

I have created a simple Flip Clock using Silverlight 3 and Expression Blend 3. It uses some simple animations to flip the hours, minutes and seconds. I hope you like it.

Get Microsoft Silverlight

You can download the sourcecode from here.

READ MORE

Control a MediaElement using a custom Behavior

0 Comments
By Fons Sonnemans, 11-okt-2009

Controlling a MediaElement in Silverlight isn't difficult. You use the Play(), Stop() and Pause() methods in your code. I have written the 'ControlMediaElementAction' Behavior which makes it even easier. You don't have to write a single line of code. The ControlMediaElementAction is associated with a MediaElement. It has a ControlMediaElementOption which you can set to Play, Stop, Pause and RewindAndPlay. The Invoke() methods controls (Plays, Stops, Pauses and RewindAndPlays) the AssociatedObject (MediaElement).

public class ControlMediaElementAction : TriggerAction<MediaElement> {

 

    protectedoverridevoid Invoke(object o) {

        switch (ControlMediaElementOption) {

            caseControlMediaElementOption.Play:

                this.AssociatedObject.Play();

                break;

            caseControlMediaElementOption.Stop:

                this.AssociatedObject.Stop();

                break;

            caseControlMediaElementOption.Pause:

                this.AssociatedObject.Pause();

                break;

            caseControlMediaElementOption.RewindAndPlay:

                this.AssociatedObject.Position = TimeSpan.Zero;

                this.AssociatedObject.Play();

                break;

            default:

                break;

        }

    }

 

    publicControlMediaElementOption ControlMediaElementOption { get; set; }

 

}

 

public enum ControlMediaElementOption {

    Play, Stop, Pause, RewindAndPlay

}

You assign a ControlMediaElementAction to a MediaElement. In Expression Blend you drag it from you Asset tab and drop it on a MediaElement. Then you can select your trigger and set all other properties from the Properties tab.

ControlMediaElementAction in Blend 3.0

In the following example I have 3 ControlMediaElementAction assigned to a MediaElement. The first is triggerd by the 'Click' event of 'buttonPlay' and uses the 'Play' option. The second is triggerd by the 'Click' event of 'buttonPause' and uses the 'Pause' option. The third is triggerd by the 'MediaEnded' event of the MediaElement and uses the 'RewindAndPlay' option, making the movie loop.

READ MORE

Silverlight XP.net

0 Comments
By Fons Sonnemans, 01-sep-2009

I'm proud to announce the Silverlight XP.net website. It is a web application where Silverlight Developers can post links to interesting information, controls, resources e.t.c. We invite you to submit your Silverlight resources.

Silverlight XP.net is a Silverlight 3.0 LOB application which uses a lot of the new techniques:

  • .NET Ria Services
  • Navigation Application (deeplinking + history)
  • Search Engine Optimization (SEO)
  • Behaviors

Silverlight XP was created by Loek van den Ouweland and me, and is currently at version 1.0. We plan to add a lot of features soon. We don’t have a feedback-function yet. Please drop comments about the website by mail.

READ MORE

Silverlight 3.0 LetItSnowBehavior

0 Comments
By Fons Sonnemans, 14-aug-2009

Silverlight 3.0 has a great new feature called Behaviors. You can use them for a lot of things, one of them is to create a SNOW effect in a canvas. I know it is not yet Christmas but I like to be prepared. If you don't know what a behavior is or how to write them read first this blog post from Andrea Boschin.

You can download the sourcecode from here.

READ MORE

ImageSlider in Silverlight 2.0

0 Comments
By Fons Sonnemans, 23-jun-2009

Today I found this blog about 15 Amazing jQuery Image Gallery/Slideshow Plugins and Tutorials. I really like the Beautiful jQuery Slider Tutorial which you can try on this page.

I wondered how easy it would be to create a similar solution using Silverlight 2.0. So I tried it and it was easy. I have used the HtmlBridge to initialize the ImageSlider with the correct images. Added some animations using Expression Blend. Used the VisualStateManager to style the RadioButtons.

You can download the sourcecode from here.

Get Microsoft Silverlight

READ MORE

Silverlight projects in Visual Studio 2010

0 Comments
By Fons Sonnemans, 19-mei-2009

I finally found some time to test the beta of Visual Studio 2010. No problems found yet. It even supports a visual designer (Cider) for Silverlight projects. You can now use it to drag & drop controls from your toolbox, add rows/columns to a grid and set properties. Things which where only possible in Expression Blend.

Cider in Visual Studio 2010

READ MORE

Playing with Silverlight 3D Perspective

0 Comments
By Fons Sonnemans, 16-apr-2009

I have created a simple rotating clock using Silverlight 3.0. It uses Databinding, Animation and the new Projection property of UI Elements to apply 3D Transformations. You will have to install the Developer Runtime first before you can see it!

Download the sourcecode

Get Microsoft Silverlight

READ MORE

Favorite MIX09 Videos

0 Comments
By Fons Sonnemans, 31-mrt-2009

READ MORE

All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.