Archives

Archives / 2009 / October
  • BulletedList in Silverlight

    Today I wanted to add a bulleted list of text items in a xaml page, as there is no BulletedList control in Silverlight, you have to do it yourself. But I don’t need a databound list, just something simple in a TextBlock, so here is what I ended with, using <LineBreak> and <Run> elements:

    <TextBlock>
        This Silverlight 3 demo uses:<LineBreak/>
        <Run>• Entity Framework and LINQ</Run><LineBreak/>
        <Run>• .NET RIA Services</Run><LineBreak/>
        <Run>• WCF</Run><LineBreak/>
        <Run>• Export DataGrid to Excel</Run><LineBreak/>
        <Run>• Insert/Update/Delete with DataForm</Run><LineBreak/>
        <Run>• Styling and ResourceDictionary</Run><LineBreak/>
        <Run>• Control Template</Run><LineBreak/>
        <Run>• Out Of Browser mode (OOB)</Run><LineBreak/>
        <Run>• Search Engine Optimization (SEO)</Run>
    </TextBlock>

    As expected, the result at runtime:

     

    Technorati Tags:
  • Samedi.NET special Silverlight event in Montreal

    The Montreal .NET Community organized a full-day Silverlight workshop last Saturday.

    The topic of the day was: “Build a business application with Silverlight 3”.

    We were 5 speakers presenting many sessions (all code, no slide) to show different tools and technologies:

    • Visual Studio 2008 SP1
    • Expression Blend 3
    • Expression Designer 3
    • .NET RIA Services
    • WCF and LINQ

    The event went pretty well, what amazed me the most is the fact that we got more than 160 attendees!!!


    So we could feel the excitement for Silverlight growing more and more, and I answered to so many questions both during my presentations and at the end of the day!!!

    To change from Northwind we used a simple Db with beers (thanks Andy):

    beers db

    I did 2 talks:

    • .NET RIA Services
    • Silverlight and SEO

    Here is what I showed during my first talk:

    • Navigation Framework
    • Manage Data
      • Entity Framework and LINQ
      • .NET RIA Services
      • DataGrid + DomainDataSource
        • Custom columns
        • DetailsRow Template
        • Sort
        • Filter
        • Group
        • Pagination
      • Activity Control
    • Export to Excel

    The download below adds more:

    • Edit, Delete (with confirm) beer with the new DataForm control.
    • Insert new beer in a ChildWindow
    • Beer details page
    • Out Of Browser mode (OOB)

    For more on .NET RIA Services and how you can add it in your existing architecture, have a look at this incredible list of posts:
    http://blogs.msdn.com/brada/archive/2009/08/02/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-summary.aspx

    I’ll write more on my second talk (SEO) in another blog post.

     

    Download source code

     

    Also check the post of my co-worker Louis-Philippe, he has lots of pictures of the event.

    Technorati Tags:
  • Silverlight presentation at the Quebec User Group

    Yesterday I did a Silverlight presentation at the Quebec User Group and my goal was to show the new features of Silverlight 3 to help build business app, so this was not quite an intro presentation with no animation and video...

    As usual I showed only 3 slides and then built live a ginormous demo from scratch ”ScottGu style” in which I took advantage of Silverlight 3 + .NET RIA Services to manage a beers db with :

    • Navigation Framework
    • Style and Theme
    • Data
      • Entity Framework
      • .NET RIA Services
      • DataGrid + DomainDataSource
        • Custom columns
        • DetailsRow Template
        • Sort
        • Filter
        • Group
        • Pagination
      • Activity Control
    • Export to Excel
    • OOB mode

    And I even had enough time for a QnA session!

    Download the Powerpoint content (french)



    Download the source code (requires .NET RIA Services)

  • [Book review] Silverlight 3 Jumpstart

    Silverlight 3 Jumpstart by David Yack, Microsoft Silverlight MVP, is a small book designed to get you started with Silverlight. I think it was the first Silverlight 3 book available.

    www.silverlightjumpstart.com

    I really enjoyed reading this book, I like the format and the fact that it goes straight from XAML introduction to MVVM in less than 200 pages! The author doesn’t spend too much time explaining what a Rectangle is and how you can animate it… (we don’t really care, right) and focus more on features that will help you build RIA business application.

    I really like the chapter on architectures presenting an overview of MVVM, Prism, CLSA, IdeaBlade and .NET RIA Services! I gives you a good starting point to learn about these new framework/pattern.

    I definitely recommend this book for any .NET developer willing to quickly become up to date with Silverlight 3; in fact, as a Silverlight Trainer myself I bought several dozens to give to my students.

    Note that this book is a premise of a next book focused even more on building business applications using Silverlight, so keep an eye on www.slria.com

     

    Technorati Tags:
  • Microsoft "All-In-One Code Framework" for Silverlight

    "All-In-One Code Framework" delineates the framework and skeleton of most Microsoft development techniques using typical examples in different programming languages.

    "All-In-One Code Framework" is a set of code samples available on CodePlex, the goal is to provide examples that are typical, extensible, structured, complete, well-documented and easy to understand.

    http://cfx.codeplex.com/

    The library covers many topics (COM, Windows 7, ASP.NET, Data Access, Office, …), and what attracted my attention is the Silverlight section!

    Here is what you get in the Silverlight download for September:

    CodeFx

    As you can see some Silverlight 3 features are featured (PixelShader, PlaneProjection, WritableBitmap) as well as many other. For example the CSSL3CustomControl project is a good start is you want to learn how to build Silverlight custom control in C#.

    Enjoy!

    Note: I am not involved in this project, if you have question please ask in the forum:
    http://cfx.codeplex.com/Thread/List.aspx

    Technorati Tags:
  • Silverlight 3 Activity control

    The Activity control is an async/background activity indicator: it shows a progress bar while data is being loaded or work is being done in the background.

    Maybe you already saw this control which comes with the new “Silverlight Business Application” project template when you install .NET RIA Services.

    Silverlight Activity Control

    Live demo here:
    http://www.davidpoll.com/Samples/ActivityControlDemo/ActivitySampleTestPage.aspx#/RiaServicesActivity

     

    But did you know that you can use this control without a .NET RIA Services project ?

    On a regular Silverlight 3 project you just need to reference the ActivityControl.dll file which remains inside the “Silverlight Business Application” project template (BusinessApplication.zip) located here:

    C#
    C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp\Silverlight\1033\

    VB
    C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\VisualBasic\Silverlight\1033

     

    Or you can download the control from its author’s website:
    http://www.davidpoll.com/Download/ActivityControl9-14.zip


    Extract the ActivityControl.dll from the zip and add a reference in your Silverlight project.

    Then you can add it in any xaml file after adding the proper namespace declaration in the header:
    xmlns:activity="clr-namespace:System.Windows.Controls;assembly=ActivityControl"

     

    The ActivityControl has several interesting properties:

    • IsActive – this can be bound to a boolean value that represents activity.
    • ActiveContent and ActiveContentTemplate: message or xaml content to display in the activity UI.
    • DisplayAfter – minimum amount of “active” time before the activity UI appears.
    • MinDisplayTime – minimum amount of time to display the activity UI.


    The code you find in .NET RIA Services samples use the IsBusy property of the DomainDataSource control to set the IsActive binding:

    <activity:Activity IsActive="{Binding IsBusy}">
        <data:DataGrid ItemsSource="{Binding Data, ElementName=employeeDataSource}" />
    </activity:Activity>

     

    But here we don’t use a DomainDataSource so we can create a DependencyProperty in code:

    public bool IsWorking
    {
        get { return (bool)GetValue(IsWorkingProperty); }
        set { SetValue(IsWorkingProperty, value); }
    }
    
    public static readonly DependencyProperty IsWorkingProperty =
        DependencyProperty.Register("IsWorking", typeof(bool), typeof(MainPage), new PropertyMetadata(false));

     

    And use it in our xaml like so:

    <activity:Activity ActiveContent="Working..." IsActive="{Binding IsWorking}">
        // Insert your UI like a DataGrid here...
    </activity:Activity>

     

    To finish set the DataContex to the class itself to be able to bind to the DependencyProperty, add this in the header of the xaml file:

    DataContext="{Binding RelativeSource={RelativeSource Self}}"

     

    On my sample, when the user click on the button I set the IsWorking property to true and use a BackgroundWorker to simulate a long async process, which automatically displays the Activity control:

    Silverlight activity control

     

    Download source code:

     

    For more detailed information and samples, follow this link :
    http://www.davidpoll.com/tag/activity-control/

     

    Technorati Tags: