Monday, June 28, 2010

Expression Blend 4: Business Application Development

Today I’ll write about support for MVVM and design-time resources. You can simplify your daily work. Read this post!

Expression Blend offers new sample data, behaviors, and project templates to support MVVM.

It includes the Silverlight/WPF Databound Application project template that offers a basic starting point for MVVM pattern applications. The UserControl with ViewModel item template is very helpful, too.

01_MVVM_0201_MVVM_03

Methods and commands of CLR objects show up just like data in the data pane. You can now bind execution of methods and commands against UI elements with drag and drop. Blend automatically generates an InvokeCommandAction or a CallMethodAction with default trigger!

01_MVVM_06 - Mod 01_MVVM_07

New Blend can generate sample data for CLR classes, even for classes that have private constructors, properties without setters and so on. If your application uses the MVVM pattern, you can generate design-time sample view models and  continue to design your application in the context of this data.

01_MVVM_08 01_MVVM_09 01_MVVM_11 01_MVVM_13 - Mod 01_MVVM_14

Modern applications are often broken into dynamically loaded modules (f.e MEF). At design time, this often leads to problems because not all required resources are available in an individual module. With Blend 4, designers can load in a temporary resource file that is only used for resource resolution at design time, enabling a great design experience even in complicated modular scenarios. When you open a project in Blend and the current document contains resources that cannot be resolved and your solution contains at least one ResourceDictionary file, the Add Design-time Resource Dictionary dialog will open.

01_MVVM_15

Below you see my sample application with all features described in this post. Runtime data is different than design-time data.

01_MVVM_17

Complete solution you can download here.

Useful links

Friday, June 25, 2010

Expression Blend 4: Conditional Behaviors & Data Store

You can now build conditional logic without the need to write code. In addition, different parts of your application can communicate via data store without writing any code, too!

When you fill user and password fields and click Login button in my sample application, user name and authentication info are written to Data Store, main menu and Home page with logged user name are displayed.

01_ConBehDataStore_03 01_ConBehDataStore_06

New SetDataStoreValueAction writes the value of a property to Data Store and optionally animates the change over time.

01_ConBehDataStore_02

Using Data panel you can manage the Data Store and its properties.

01_ConBehDataStore_01

New DataStoreChangeTrigger fires when a specified property in the Data Store changes.

01_ConBehDataStore_04

You can drag a property from the DataStore onto the art board.

01_ConBehDataStore_05 - Mod

Useful links

Sunday, June 20, 2010

Expression Blend 4: Fluid UI - Enhanced FluidMoveBehavior & Layout States

In Blend 4, Fluid Layout has many new tricks. You can now define layout animations between a master list and a detail view and animate things that move between lists. You can also animate the process of items being added to and removed from a ListBox.

An exciting enhancement has been made to the FluidMoveBehavior.

FluidMoveBehaviorMasterDetail
01_FluidMoveBehavior_MasterDetails_01 01_FluidMoveBehavior_MasterDetails_0201_FluidMoveBehavior_MasterDetails_03 - Mod

By using FluidMoveBehavior together with FluidMoveSetTagBehavior, you can animate a transition from a specified starting point, even if that initial location is specified only by a reference to the data that is displayed in your application and may exist in a different scope. Data tagged by FluidMoveSetTagBehavior is available for use with FluidMoveBehavior by using a hidden data store.

FluidMoveBehavior is optimized for two main scenarios: animating from a master list to a detail view and animating list items from one list to another.

FluidMoveBehaviorListToList
02_FluidMoveBehavior_ListToList_0102_FluidMoveBehavior_ListToList_03

In Silverlight 4, a special VisualStateGroup called LayoutStates has been added specifically for animating adding items to and removing items from a ListBox (or custom ItemsControl). You may have a look at my previous post (updated sample you can get from here).

If you also apply a FluidMoveBehavior behavior to the items panel of the ListBox, existing items will smoothly make room for entering new items.

02_FluidMoveBehavior_ListToList_02

Useful links

Thursday, June 10, 2010

My offline extension of DeploymentCatalog

DeploymentCatalog works well in many scenarios. However, when you start  Silverlight out of browser application in offline, cached .xap is not found. So I have extended standard DeploymentCatalog to support offline scenario.

How my offline extension works?

In online out of browser application downloads (or gets from cache) .xap file and saves it  in an additional place - MyDocuments folder. I use trusted mode, so saving works without user interaction and space limit.

When you start out of browser application in offline, .xap file is loaded from MyDocuments folder.

MEF_Offline_Xap_2

I have created DeploymentCatalogWithOffline based on modified DeploymentCatalog sources.  I have changed only implementation of  HandleOpenReadCompleted method (see the screenshot below).

MEF_Offline_Xap_1

You can download complete solution here.

Tuesday, June 8, 2010

Silverlight 4 RTW Samples - part II

I wrote a post with part I of my Silverlight 4 RTW practical summary a  few days ago. Today I’ll continue this topic.

I sign changes in my samples:  

  • API changes or/and new features
  • new sample showing new features

Let’s continue …

9. Out of browser applications - sandboxed (SandboxedOutOfBrowser, MultiTouchPuzzle)

Now you can silent install out of browser application without … browser. You can also launch application without installing.

10. Out of browser applications - trusted (TrustedOutBrowser)

Upon installation of an elevated trust application end user’s will be presented with dialogs shown below.  XAP signing reassures end users of the authenticity of an application’s publisher and that the code has not been tampered with.

Trusted_OOB_WithoutSigningTrusted_OOB_WithSigning

You should experiment with custom window chrome! Your application may look more distinctive!

Silverlight 4 adds the ability to discover when an OOB application’s window is being closed. The Closing event offers the opportunity to cancel this operation in trusted applications.

Trusted_OOB_CustomChrome

11. Implicit styles (ImplicitStylesDemo)

12. CompositeTransform (TransformDemo)

13. MEF (MEF, MEF2, HousePlanner, ExtensibleGrid, SilverlightMEFNavigation)

MEF in final Silverlight 4 has some changes from beta. For example, it contains new DeploymentCatalog.

14. Communication - multicast, authentication & WCF (MulticastChat, ClientHttpStackAuth, WcfTcpBinding, WcfDuplexTcpBinding, VideoChat)

When using a service configured with NetTcp binding, Silverlight does not honor TCP policy served by the server at port 943. This is one of some known WCF issues in Silverlight 4.

WCF_Video_Chat

15. Communication - WCF Data Services (WcfDataServicesDemo, BinaryDataStreamingDemo)

I have added demonstration of server-driven paging and partial entity sets to WcfDataServicesDemo example.

You can work more efficiently by using Visual Studio 2010 Data Sources window !

WCFDataServices_DataSourcesWindow

OData protocol defines a mechanism for accessing binary data separate from an entity to which it belongs. OData service can expose large binary data as a media resource that belongs to a media link entry. The WCF Data Services client for Silverlight can consume a media resource from an OData service as a binary stream.

WCFDataServices_BinaryStream1WCFDataServices_BinaryStream2

16. XML - XPath (XmlDemo)

Silverlight 4 RC/RTW introduces XPath support including XPathNavigator and LINQ to XML extension methods for evaluating XPath expressions on your XElement objects!

XmlXPath

17. New C#4 & platform features (CSharp4, ModifyHTMLbyNET)

18. ViewBox (ViewBoxDemo)

19. Toolkit - ContextMenu & Theming (ThemesDemo)

Silverlight 4 Toolkit April '10 introduces some new features and changes

ThemesDemo example shows new SystemColors theme, using themes at application and page level, custom theme, changing themes at run-time with ContextMenu control.

Toolkit_Themes_App Toolkit_Themes_Menu_Changing Toolkit_Themes_Menu_Xaml Toolkit_Themes_Menu_Code

All samples from part two you can download here

 

Silverlight 4 Tools for Visual Studio 2010 also contains some interesting features. See great video on Silverlight TV!