November 2008 - Posts

From Wikipedia: “ASP.NET Dynamic Data is a web application scaffolding framework from Microsoft, shipped as an extension to ASP.NET, that can be used to build data driven web applications.


So if you use VS2008 and .NET 3.5 SP1 you can take advantage of ASP.NET Dynamic Data to quickly create a full administration website (UI and CRUD) over a model (LINQ To SQL or better Entity Framework) on top of some db tables, and all this in about 3 minutes!

Furthermore the system is very flexible and you can customize the look and feel of the generated web pages through a set of pages and user controls available on the DynamicData folder.

But the default “3 minutes” experience create a web app that exposes CRUD operations on every tables/every columns…

Default screen while editing the products table:

What you may want to customize:

  • Prevent some tables to be “scaffolded”
  • Change table display name
  • Format columns data
  • Hide some columns (like Ids)

This is the part where you’ll need to write a bit of code. In App_Code folder create new file that will hold several partial class to provides metadata information. You need to add 2 class for each entities in your model, one partial class with the name of the entity, and one sub-class to set metadata. The second one is “attached” to your entity class with the MetadataType attribute.

C# snippet for Products entity:

[MetadataType(typeof(Products_Metadata))]
public partial class Products
{
    [TableName("Company products")]
    public class Products_Metadata
    {
        [ScaffoldColumn(false)]
        public object ProductID { get; set; }
 
        [DisplayName("Name")]
        public object ProductName { get; set; }
 
        [DisplayName("Price"),DisplayFormat(DataFormatString = "{0:c}")]
        public object UnitPrice { get; set; }
 
        [DisplayName("Stock")]
        public object UnitsInStock { get; set; }
 
        [ScaffoldColumn(false)]
        public object ReorderLevel { get; set; }
 
        [ScaffoldColumn(false)]
        public object Discontinued { get; set; }
 
        [ScaffoldColumn(false)]
        public object QuantityPerUnit { get; set; }
 
        [ScaffoldColumn(false)]
        public object UnitsOnOrder { get; set; }
 
        [ScaffoldColumn(false)]
        public object Suppliers { get; set; }
 
        [ScaffoldColumn(false)]
        public object Order_Details { get; set; }
    }
}

To remove a table, use the ScaffoldTable(false) attribute.

Products table will now appear as “Company products” (TableName attribute).
I keep only 4 columns and rename them (ScaffoldColumn and DisplayName attributes).
Price column is formatted as currency (DisplayFormat attribute).

See the result:

 

Technorati Tags:
Posted by pluginbaby | 6 comment(s)
Filed under: ,

SilverlightDefaultStyleBrowser is a free WPF tool by David Anson that allows you to inspect the styles and templates of the Silverlight controls.

Follow this link to learn more and download the app:
http://blogs.msdn.com/delay/archive/2008/09/26/preserving-access-to-silverlight-2-s-generic-xaml-resources-silverlightdefaultstylebrowser-updated-for-the-silverlight-2-rc.aspx

 

Technorati Tags:
Posted by pluginbaby | with no comments
Filed under: ,

When I am training Silverlight I am often asked by designers how to find resources on Silverlight/XAML/Expression, so here is a post for them:


First you can find lots of Expression Studio videos training in the new Microsoft videos portal:
www.microsoft.com/video/en/us/categories/products/expression


Lynda.com provides videos training on Expression Blend and Expression Design:

 

Expression Design tutorials on the Microsoft Expression Team blog:
http://blogs.msdn.com/expression/pages/samples-and-tutorials-gallery-expression-design.aspx


Here are some XAML exporters to help you do Silverlight with your assets from Adobe tools:


The fantastic NibblesTutorials website (Expression Blend):
www.nibblestutorials.net

This blog post collect free Silverlight controls and tools available on the net:
www.webresourcesdepot.com/free-silverlight-controls-and-tools-for-brighter-websites/

And finally this interesting blog:
www.designwithsilverlight.com

 

Also as a designer you NEED to know about the Expression Professional Subscription, for a very good price ($999 USD) you get:

  • Expression Studio 2
  • Visual Studio 2008 Standard
  • Windows Vista Business
  • Windows XP SP2
  • Office Standard
  • Office Visio Professional
  • Pre-configured virtualized server environments (VPC)
  • Virtual PC (to use the VPC)
  • Parallels Desktop for Mac (a 3rd party application to run Windows OS on Apple hardware concurrent with OSX)

So typically if you are a MAC designer with no Microsoft platform tools you get everything you need to get started and create awesome user experience applications with Silverlight!

 

Formation Silverlight

I’ve just finished teaching my first Silverlight Tour training in Montreal, people were very excited about Silverlight 2 and I got lots of interesting question I thought I could share (with my answers!):

* Can you export XAML from Adobe software's?

There are some plug-ins available to export XAML from Adobe tools:

These tools are not always perfect and some only export XAML for WPF, I think the best way is to import your graphics in Expression Design then export XAML.


* How do you localize a Silverlight app ?

There is no “Generate Local Resource” support to localize XAML UI.
So this is not as easy as ASP.NET but it is possible to use multiple xap files for your manually generated resx as explained in this link:
http://blogs.msdn.com/webdevtools/archive/2008/06/10/localizing-a-silverlight-application.aspx


* Animation: can we set Duration property in milliseconds ?

XAML syntax for Duration is: Duration=”00:02:50” (0 hour, 2 minutes, 50 seconds).
To use milliseconds you can simply set: Duration=”00:00:00.5” (50 milliseconds)
or by code: obj.Duration = TimeSpan.FromMilliseconds(50);


* Animation: Can we use Motion Path ?

No, motion path can be used in WPF but not in Silverlight.


* Can you use Silverlight in a Windows Forms app ?

You can use a WebBrowser control and set its Url property to your web page hosting Silverlight app.


* What about printing a Silverlight app ?

Currently there is no particular print support in Silverlight. It will print “as is” in IE but not in Firefox (blank area).


* Do multiple Silverlight app can share Isolated Storage settings?

Yes, xap from the same domain can access datas set via IsolatedStorageSettings.SiteSettings[…].

 

Also some students found a bug in Visual Studio 2008: You don’t have XAML IntelliSense in a DataTemplate:

<ListBox x:Name="myListBox"
         Width="325"
         Margin="8">
  <ListBox.ItemTemplate>
    <DataTemplate>        
       no IntelliSense here...
    </DataTemplate>
  </ListBox.ItemTemplate>
</ListBox>

 

Check our website for the next Silverlight training in french!

 

Posted by pluginbaby | 1 comment(s)
Filed under:

Microsoft has launched a new videos portal in Silverlight.

> www.microsoft.com/videos

Good news, there is an Expression Studio category with already more than 140 videos!!

Silverlight Extensions is a nice project which group useful Silverlight controls and best practices:

Controls Helpers Players
  • Treeview
  • Captcha
  • Virtualized stack
  • panel
  • Dockpanel
  • Flow layout
  • Viewbox
  • GoogleMap
  • Virtual earth
  • Change tracker
  • Binding comparer
  • Bootstrap
  • HTML Editor
  • CommandService
  • Deepzoom helpers
  • Mouse wheel Listener
  • Various comparers
  • Google analytics
  • Browser history
  • Deepzoom
  • Video
  • Photo

You can download all this for free at CodePlex:
http://www.codeplex.com/SLExtensions/

Same question as for Silverlight Contrib: will the controls merge with Silverlight Toolkit ?

Have a look at the live Showcase: http://www.slextensions.net/

Silverlight Extensions 

 

Technorati Tags:
Posted by pluginbaby | 3 comment(s)
Filed under:

IE8 MSDN

Lately I wrote an article for MSDN to introduce Accelerators and Web Slices in IE8 and show how to build them.

Here is an overview:

Web Slices bring the user’s favorite data (sports scores, weather reports, stock quotes, etc.) directly into the Favorites Bar. So Web Slices are like snippets of a page that a user can subscribe to. Changes and updates are retrieved and users are notified visually of the updated information status. Like any page, a “slice” can display text, links, pictures and even RIA elements (Silverlight!)… think about RSS on steroids.

[…]

Creating a Web Slice
Web Slices can be hosted in any web page. In fact you just have to define which part of you page can be “sliced” for the user. That means that you can turn any part of an existing web page into a Web Slice!

Web Slices use a combination of the hAtom microformat and the Web Slice format to describe a subscribable portion of a webpage.

hAtom is a microformat for content that can be syndicated, primarily but not exclusively weblog postings. hAtom is based on a subset of the Atom (http://www.atomenabled.org/) syndication format. hAtom will be one of several microformats open standards. More information

So to enable a Web Slice on your website, you just annotate your page with specific class names for the title, description, and content.

Here is the basic skeleton of a Web Slice:

<div class="hslice" id="sliceId"> 
  <p class="entry-title">My Slice Title</p> 
  <div class="entry-content">
  </div> 
</div>

hslice defines the Web Slice section and must have an Id.
entry-title is the title which appears in the favorites bar.
entry-content is the body of your Web Slice (you can use any HTML content here).

[…]

Accelerators in IE8 are contextual services to quickly access information from another website in your current browser page. The goal here is to be more efficient than the old "copy-navigate-paste" model. As soon as users select some text in a page, a blue icon appears to list available accelerators. Clicking on an accelerator opens a new tab with desired results. Optionally accelerators can have a preview window.

For example, suppose you’re on a page with a street address. You can highlight the address and choose an Accelerator such as Map with Live Maps. The accelerator will then display the map in a pop-up or open another tab, depending on how the Accelerator has been written for that site.

[…]

Creating an Accelerator
Building an Accelerator is really just about creating an XML file which describes your service. Results can be fetched from any service that can be queried over HTTP (GET or POST requests). This includes popular search engines like Live Search or Google but also sites such as Wikipedia, Facebook, eBay, Yahoo, Twitter or Digg.

[…]

Here is a sample code using the Live Search query URL passing the user’s selected text as “q” parameter in querystring to get related images:

<?xml version="1.0" encoding="utf-8"?>
<os:openServiceDescription xmlns:os="http://www.microsoft.com/
schemas/openservicedescription/1.0"
>
  <os:homepageUrl>http://search.live.com/</os:homepageUrl>
  <os:display>
     <os:name>Search Images with Live Search</os:name>:
     <os:description>Find related images with Live Search</os:description>
     <os:icon>http://search.live.com/s/wlflag.ico</os:icon>
  <os:display>
  <os:activity category="Search">
     <os:activityAction context="selection">
       <os:execute action="http://search.live.com/images/results.aspx" method="get">
         <os:parameter name="q" value="{selection}" type="text"/>
       <os:execute>
     </os:activityAction>
  </os:activity>
</os:openServiceDescription> 

The heart of your Accelerator is defined by these XML elements. The XML document is based on the OpenService specification:

os:activityAction specifies the interaction with the service provider based on the target of the Accelerator. The optional context attribute specifies the target: document, selection (default), or link.

os:execute specifies the action (page to call) when the user invokes the Accelerator and the method (GET or POST).

os:parameter specifies the parameters for the page. Note the use of a special variable {selection} which represents the user’s highlighted text. Alternatively, the variable {link} can be used to get the href of a selected link.

[…]

Read the full article here:
http://www.microsoft.com/youshapeit/msdn/content/knowledge/2008-10/ie8_improve_the_browsing_experience.aspx

Also check my Accelerators available on the IE gallery:

  • Search Images with Live Search
  • Search with Google Canada
  • Find Songs on Zune Social *
  • Find Albums on Zune Social *
  • Find Artists on Zune Social *

  • * For some reasons Microsoft has removed my Zune Accelerators. Sorry about that.

    Technorati Tags: ,,
    Posted by pluginbaby | 1 comment(s)
    Filed under: ,

    Interested in building Line of Business app with Silverlight ?

    Check out this presentation from Jamie Cool at PDC2008:

    http://channel9.msdn.com/pdc2008/PC11/

    You may want to go straight to 30min on the talk to get the good stuff…
    Jamie shows what’s coming in Silverlight 3: a new framework to help you build business focused applications:

    • Data access with client side ObjectDataSource!
    • Silverlight Business Logic Class (used inside Silverlight without adding a service reference!!)
    • Validator controls, validation rules enforced by server–side business class
    • Navigation workflow, browser history integration
    • Login control, roles

    This is coming… and this is huge! This reminds me of what was ASP.NET 2.0 compared to ASP.NET 1.1!

    You shape it

    Microsoft has a new web site to start the excitement on his new dev technologies: IE8, WPF, Silverlight and Windows Mobile. It is called {You shape} it and focus on Design, Development and IT Management in a nice claymotion Silverlight UI.

    http://www.microsoft.com/youshapeit/

    MSDN is part of this portal (www.microsoft.com/youshapeit/msdn) and I am a contributor as I wrote the article on IE8 development “IE8: Improve the Browsing Experience” that shows how to build Accelerators and Web Slice, check it out!

    My Silverlight sessions at TechDays Montreal were a great success and generated so many questions like “Is ASP.NET dead ?”, “What about Silverlight vs WPF XBAP ?” or “Would you recommend Silverlight for line of business application ?” that we decided to create a FAQ and it was published on the Canadian Developer Connection blog thanks to Qixing:

    http://blogs.msdn.com/cdndevs/archive/2008/11/13/silverlight-faq-from-techdays.aspx

     

    Technorati Tags:
    Posted by pluginbaby | with no comments
    Filed under: , ,
    More Posts Next page »