Gepost door: antonidol | vrijdag 20 november 2009

Top 10 Silverlight 4 beta features for Designers

Silverlight 4 beta is out and delivers several new features for programmers, media people and designers. As a designer I was most interested in some specific features, so I’d like to share my top 10 with you.

10. Command property on buttons and hyperlink

I’ll have to explain this one. John Papa’s whitepaper only speaks of the MVVM pattern context, but in the WPF world commands are well known. Actually it is a feature not unlike Behaviors, because they encapsulate programming code in a simple property on a button or a hyperlink. The action that follows when clicking that button or hyperlink is determined by the command. Also, it is possible to include a parameter that the command can use. Thus it is used more dynamically and is more flexible. When developers create commands, designers can easily connect them as a simple property of a button or hyperlinkbutton.

<Button Content="Load" Width="120"
        Command="{Binding LoadProductsCommand}"
        CommandParameter="{Binding Path=Text, ElementName=MyFilterTextBox}"/>

9. StringFormat, TargetNullValue, FallbackValue on Data Binding

Again, maybe not straightforward, but these additions to the data binding functionality of Silverlight helps designer to format the results of data binding with more ease. TargetNullValue will show a value when the binding has null as a result, so you can insert a zero or other sensible value instead. The FallBackValue is about the same, but it shows up when a binding is unsuccessful. You can apply a different value instead. The best of the three is the StringFormat property, which allows you to format the text resulting from data binding. This way a designer can easily indicate that output is a currency or a percentage or a date in a specific format.

<TextBox Text="{Binding Path=UnitPrice, Mode=TwoWay, StringFormat=C}" />

<TextBox Text="{Binding Path=Discount, Mode=TwoWay, StringFormat=P}"/>

<TextBox Text="{Binding Path=OrderDate, Mode=TwoWay, StringFormat=’MM-dd-yyyy’}"/>

8.Webbrowser control and HTML brush

This seems like a nobrainer, but some restrictions are present. This only works in sandboxed applications, which means that you have to have an Out-Of-Browser application. You can use inline HTML (NavigateToString), an inline HTML document (Navigate) or an URL (Source).

string html = "<HTML><HEAD></HEAD><BODY style=’margin:0 padding:0′><IFRAME width=’100%’ style=’overflow: hidden;’ height=’100%’ src=’http://www.microsoft.com&#8217; /></BODY></HTML>";

HtmlContent.Navigate(html)

The HTML brush lets you paint with a webpage, so you can use it as a Brush in any Shape.

<Path Data="…" >

    <Path.Fill>

        <HtmlBrush x:Name="htmlBrush" AlignmentX="Left" AlignmentY="Top" Stretch="None"/>

    </Path.Fill>

</Path>

And in C# set the source: htmlBrush.SetSource(MyWebBrowser);

7. CompositeTransform

This makes a designers’ live a bit easier: combine Translation, Rotation and Scale in one go:

<Rectangle Height="100" Width="100" Fill="Red">
    <Rectangle.RenderTransform>

        <CompositeTransform ScaleX="2" Rotation="45" TranslateY="42"/>

    </Rectangle.RenderTransform>

</Rectangle>

6. Webcam and Microphone support

This one is self-explaining, but… What are designers and developers going to do with it? Check out the blog-post by Rob Houweling on the Silverlight and Expression Insiders site for details about this feature.

5. Rich Text Area control

Finally a way to create richer text experiences using the Rich Text Area. This will end the struggle with Run elements in TextBlocks to change a color, font or font size inside a text object. The Rich Text Area control welcomes every type of content. This includes other controls like Images and UI controls. Create bold, italic, colored text inside a block of text with ease using the Rich Text Area control. Will this lead to the inclusion of FlowDocuments in Silverlight one day?

4. ViewBox

A ViewBox is a handy container that allows you to scale up or down any graphic or large element that you want to display on a screen. Use the original sizes for the content and set the ViewBox to the size you want the content to show up. It’s that easy and very convenient at times. A ViewBox can contain only one element inside. It’s StretchDirection can be UpOnly, DownOnly or Both. The content can be Stretch-ed using None, Fill, Uniform and Uniform to fill, just like it’s WPF version.

<Viewbox x:Name=”iconSize” Margin="5" Width="64" Height="64">

    <Image Source="aHugeImage.png"/>

</Viewbox>

3. Fluid UI States for ItemsControl

I’d be very interested to see what designers and developer create with this feature. Create an ItemsControl and hook up interesting appearing and disappearing animations when adding or deleting items from the control. This not only allows you to animate ListBoxItems with ease, but opens the door to exiting navigation using items in ItemControls. Who’s up for the challenge? The new visual states are: BeforeLoaded, Loaded, and Unloaded.

2. Implicit Style

Styling an application helps in acceptance and defining a look for different groups of users. Implicit Styles will help a lot in implementing Themes. Actually the ToolKit people have already removed the Implicit Style Manager that took care of this. Just omit the x:Key and all controls of a the specific type will take on the style you give them. Combined with swapping ResourceDictionaries you have theming solutions available.

1. Printing support

Even though it is only possible in code, printing support is a huge improvement from a designers’ point of view. This is the most requested feature for a reason. It is possible the print the content of a page using the LayoutRoot, or any other container that you specify. It is also possible to print objects that are entirely invisible on the screen, but you’ll have to build a tree of objects in memory a feed that to the print command. This opens up enough possibilities to satisfy business consumers. So output your work to printers everywhere…

PrintDocument pd = new PrintDocument();

pd.PrintPage += (s, args) => {

    args.PageVisual = LayoutRoot;

};

pd.Print();

These are the features that caught my eye as a designer. Some didn’t make it to the top ten, like the WordEllipsis TextTrimming property, Right Mouse Click Events and ScrollWheel events and ClipBoard support. Other features are more interesting for media people or developers. Check out Tim Heuer’s blog or John Papa’s white paper for all details on all new Silverlight 4 features.

Njoy!


Responses

  1. nr 8.Webbrowser control and HTML brush
    It’s the other way around: The HTML brush only works in the out-of-browser mode running in elevated trust mode. With your application in the plugin in a browser i believe it shows the URI/URL


Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit / Bijwerken )

Twitter-afbeelding

Je reageert onder je Twitter account. Log uit / Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit / Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit / Bijwerken )

Verbinden met %s

Categorieën

%d bloggers op de volgende wijze: