Friday, December 19, 2008

PDC version of "Quadrant" - some limitations and questions

"Quadrant" is a visual tool for models created with the code name “Oslo” platform. There's a PDC virtual machine with "Oslo" and "Dublin" and it includes pre-alpha version of  "Quadrant", documentation and some Hands-On Labs. "Quadrant" seems to be cool, but PDC version has some limitations.


  1. You can create instances and custom views of models, but editor for creating model schema with "M" language will be integrated in next builds.
  2. You can make new model with "M" using Intellipad or Visual Studio and import compiled "M" image to "Oslo" repository. But current version of  "Quadrant" can't read models other than Microsoft samples !  I have tried to read my model and "Quadrant" Explorer has found it in Microsoft.Repository.Load only. Other people also have the same problem.
  3. What about more advanced customization than changing icon, category, default view, size of columns, adding property to display? How can I change f.e shape for instance of model? How can I write custom designer like workflow designer or business process designer?

I wait for next CTP of  "Quadrant" to read my models from repository.

BTW I'm keen on "Oslo" technology, so I wrote post with my questions about "Oslo" in community forum.

Thursday, December 11, 2008

Silverlight Toolkit December 2008

This post will be about new version of Silverlight Toolkit.

In the December 2008 release Silverlight team has included: 100 new features and bug fixes, 3 new themes (Whistler BlueBureau Black, Bureau Blue), better design-time support, charting improvements, and enhanced UI Accessibility features.

WhistlerBlue   BureauBlack   BureauBlue

For more information about changes  you see:

Wednesday, November 19, 2008

Silverlight 3: H.264 video + 3D hardware acceleration !

This post will be about new features in next version of Silverlight, which is planned for availability in 2009.

On November 16th Scott Guthrie revealed Silverlight 3 will include:

  • H.264 video support
  • 3D support and GPU hardware acceleration (That sounds great !)
  • richer data-binding support
  • additional controls

These are just a small sampling of the improvements.

Friday, November 14, 2008

Future of Silverlight

Last week I saw three interesting PDC presentations about Silverlight. So in this post I write about Silverlight future components and mobile edition of the technology.

PDC Silverlight sessions I've seen:

Microsoft Silverlight 2 for Mobile: Developing for Mobile Devices

pdc mobile

Silverlight 2 for mobile supports .NET programming model. You don't need to change code of your Silverlight 2 application, but you can recognize displaying device (DeviceInformation class) to do some actions (for example making full-screen only for mobile devices). You can also use wrapper to recognize gestures.  Public CTP will be available  at Q1 during 2009. Excellent session with many practical demos! (at the end very interesting demo with ducks which depend on position of mobile phone).

Microsoft Silverlight Futures: Building Business Focused Applications

business framework

Second part of this session 'Futures'  is quite interesting. In the future Microsoft will add page navigation and frameworks for business applications (for example validation, authentication, business objects, data paging). Business Logic Framework will make building n-tier applications simpler. You should see practical demo with these new components. Team is also working on editable Visual Studio Silverlight designer, design time databinding support, core platform enhancements and many new controls.

Silverlight Controls Roadmap

silverlight toolkit 

This session is about Silverlight Toolkit (WPF controls: DockPanel, WrapPanel, TreeView, Expander, Label, ViewBox, HeaderedContentControl, HeaderedItemsControl + new controls:  AutoComplete, Charting, NumericUpDown + 6 themes with Implicit Style Manager). IMHO AutoComplete control is very useful and cool!  Silverlight Toolkit will be updated with new components ( Accordion, ListView) and many improvements (f.e charting, designer).  What's more - Microsoft thinks about making more new controls (MIX 2009 - MediaPlayer, TimePicker, Carousel, Rating, MaskedTextBox; in future: InPlaceEditing, AppoinmentCalendar, ImageMap, FileUpload, Menu, Slideshow).

Wednesday, November 12, 2008

Silverlight - value inheritance

This post will be about value inheritance of dependency properties in Silverlight.

You cannot write custom dependency property with inheritance. There is the fixed set of predefined properties with value inheritance, for example: FontFamily, FontSize, FontStretch, FontStyle, FontWeight, Foreground.  There was a problem with performance and Silverlight team did a number of optimizations specific to those particular properties. All properties have the same precedence order:

1.  animations -> 2. local value (and binding) -> 3. templated property -> 4. style -> 5. value inheritance -> 6. default value

BTW,  Silverlight Toolkit introduces one more way to customize controls  - themesTheme  has lower priority than style, but higher than value inheritance.

Monday, November 10, 2008

Links: Silverlight 2 RTW, Silverlight Toolkit

Here are some useful Silverlight  links which I visited last month.

Silverlight 2 Released: New controls, tools, announcements!   -  what's new in Silverlight 2 ?  Eclipse support; changes in text rendering, controls, networking, Visual Studio support of ADO.NET Data Services,  a font manager in Blend 2 SP1 and more.

Silverlight™ Dynamic Languages SDK - IronPython, IronRuby, and Managed JScript in Silverlight

Silverlight Tools RTW Released! - update for Silverlight Tools


Unit Test Framework for Silverlight:



Silverlight Toolkit:  



Monday, October 6, 2008

From Silverlight 2 Beta 2 To RC0

On September 25th Microsoft released Silverlight 2 RC0 (for developers only). At the end of September I migrated my SL 2 Beta 2 application to new version. First my project didn't compile, later I had some run-time errors ... Finally I have working SL2 RC0 application. 

Some changes I have noticied when I did migration:

  1. generic.xaml was moved underneath the themes folder under control library project

  2. IsEnabled property was added to Control class

  3. RoutedEventArgs.Source  was changed to OriginalSource

  4. MouseEventArgs.Handled was moved  to MouseButtonEventArgs (SL team: In Beta 2 timeframe, we heard a lot of feedback that a lot of events are marked as Handled internally. This had caused a lot of troubles. Generally speaking, you should only mark an event as handled when other event handlers expects you to do so. But it's unlikely that is a requirement, especially for events using MouseEventArgs, such as MouseEnter/Leave/Move. Leave this property will cause more confusions than the problems it solves. So we decide to remove it from some events, while keep it on the other, when necessary. More information:

  5. CancellingEdit and CommittingEdit events of DataGrid control were removed (SL team: The event was there in Beta 2, but it didn't work correctly so it was removed for RTM.  We are hoping to bring it back in SL 3. More information:

  6. Some changes in styles and templates (When I compiled my project, I got warnings and errors:  " The property '_UnknownContent' does not exist on the type 'ResourceDictionary' in the XML namespace '' " and " The type 'List`1' is inside a ResourceDictionary and does not have a key". I had errors, because I had used skins like here.  I changed some namespaces and styles to new format, but I still had build errors.  Finally, I  created new project, copied files from old project and I got warnings  - not errors!  Amazing, but it helped me!  I have ignored warnings and my project has worked correctly! )

  7. DataGridCellsPresenter, DataGridColumnHeader, DataGridColumnHeadersPresenter, DataGridDetailsPresenter, DataGridRowHeader, DataGridRowsPresenter classes were moved to namespace System.Windows.Controls.Primitives

  8. ContentPresenter derives from FrameworkElement instead of Control

  9. Some changes in animations:  You get exception " Operation is not valid on an active Animation or Storyboard. Root Storyboard must be stopped first."  when you change  Storyboard.TargetNameProperty  on an active Storyboard. You should stop Storyboard before changing the property.

  10. Some changes in ContentControl: Now content doesn't stretch automatically to borders of the control. I set VerticalContentAlignment and HorizontalContentAlignment properties to Stretch value.

  11. IsTabStop default value was changed to true.

  12. Some changes in databinding:  With Beta2 you can make two way binding without specyfing Path. Now you get exception "Two way binding requires Path"

  13. Some changes in wrapping text for TextBlock:  Parts of the text with more than one word are hidden. With Beta2 it works correctly, it seems to be a bug.

For more information about changes  you see  Breaking Changes Since Beta 2 document, RC0 documentation or Silverlight forums.

Thursday, September 18, 2008

Silverlight Tip 8#: Measurement and layout pass in Silverlight run asynchronously!

If you try to use ActualWidth and ActualHeight properties, they sometimes are equal zero! Why? How fix it? You should read very good Tamir Khason's post about it.

Wednesday, September 17, 2008

Silverlight Tip 7#: Handling ListBox MouseLeftButtonDown event with VisualTreeHelper

In Silverlight 2 beta 2 ListBoxItem (and ListBox) doesn’t trigger MouseLeftButtonDown event anymore! You can add handler for this event in XAML of ItemContainerStyle. I wrote post about it 9 days ago.

If you wouldn't specify the event handler in XAML, you have a problem: you can't modify code of ListBoxItem class. But you can use visual tree after loading ListBox.

You can examine the visual tree structure with VisualTreeHelper class. I have written recursive method to get all visual elements which parents are objects of a specific type:

private static List<UIElement> children = new List<UIElement>();


private static void GetChildrenWithParentRec(UIElement parent, Type targetType)
int count = VisualTreeHelper.GetChildrenCount(parent);
if (count > 0)
for (int i = 0; i < count; i++)
UIElement child = (UIElement)VisualTreeHelper.GetChild(parent, i);
if (VisualTreeHelper.GetParent(child).GetType() == targetType)
GetChildrenWithParentRec(child, targetType);

I have used this method to obtain visuals which are children of ListBoxItem elements of ListBox control. Before you show ListBox, you can use code:

//GetChildrenWithParent uses GetChildrenWithParentRec
List<UIElement> children = ChildrenHelper.GetChildrenWithParent(listBox, typeof(ListBoxItem));

if (children.Count > 0){
foreach (UIElement el in children)
el.MouseLeftButtonDown += new MouseButtonEventHandler(ListBoxItem_MouseLeftButtonDown);

It works for me.

Friday, September 12, 2008

Silverlight Tip 6#: How to start editing cell of DataGrid by pressing text key

When you press text key (f.e 'a') on selected cell of MS Excel sheet, you automatically start write to the cell. Why don't implement this behavior with Silverlight DataGrid control? I have written some code to implement it:

void dataGrid_KeyDown(object sender, KeyEventArgs e)
//editing: bool flag which you set in BeginEdit, CancelEdit, CommitEdit event handlers
if (!editing)
//IsTextKey: custom function to check if pressed key is a text key (f.e letter, digit)
if (IsTextKey(e))

void dataGrid_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
if (e.Column.DisplayIndex == 0)
TextBox t = e.EditingElement as TextBox;


KeyEventArgs args = e.EditingEventArgs as KeyEventArgs;

if (args != null)
if (IsTextKey(args))
//GetStrFromKey: custom function to get char from pressed key
//There isn't KeyPress event and KeyChar property of KeyPressEventArgs
t.Text = GetStrFromKey(args);
t.Select(t.Text.Length, t.Text.Length);

Thursday, September 11, 2008

Silverlight Tip 5#: DataGrid PreparingCellForEdit event

Recently I've used DataGridTemplateColumn in DataGrid control and I've implemented selecting text in cell before editing. This is standard behavior of predefined DataGridTextColumn, but using DataGridTemplateColumn you must implement it yourself (sample code below).

void dataGrid_PreparingCellForEdit(object sender, DataGridPreparingCellForEditEventArgs e)
if (e.Column.DisplayIndex == 0)
TextBox t = e.EditingElement as TextBox;

int length = t.Text.Length;


KeyEventArgs args = e.EditingEventArgs as KeyEventArgs;

if (args != null)
if (args.Key == Key.F2)
t.Select(length, length);
t.Select(0, length);

Wednesday, September 10, 2008

Silverlight Tip 4#: How to detect user clicks outside of your control

In order to do this you may find application root and add mouse click event handler to it:

private void MyControl_Loaded(object sender, RoutedEventArgs e)

FrameworkElement root = Application.Current.RootVisual as FrameworkElement;
if (root != null)
root.MouseLeftButtonDown += new MouseButtonEventHandler(root_MouseLeftButtonDown);

and check when user clicks:

void root_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
double x = e.GetPosition(this).X;
double y = e.GetPosition(this).Y;

if (x < 0 || x > this.ActualWidth || y < 0 || y > this.ActualHeight)
//to do

But this is not ideal solution, because it doesn't work when you click outside your control and on the control which handles MouseLeftButtonDown event (for example Button). For more information see:

Tuesday, September 9, 2008

Silverlight Tip 3#: ScrollIntoView

When you programmatically set selected item in a ListBox control and the item is unvisible, the Listbox doesn't automatically scroll to make it visible. But you can use ScrollIntoView method.

this.DropDownListBox.SelectedIndex = index;

Monday, September 8, 2008

Silverlight Tip 2#: How to implement a 'Hover-Selection' for the ListBox?

I'd like my control popup (see previous post) is similar to popup of combobox with hover-selection. There is no built-in ComboBox in Silverlight 2 Beta 2 and I've used ListBox control. But you can't select ListBoxItem by moving mouse on it.

Norbert Eder has written interesting post about how to implement it for the WPF ListBox. This solution has one bug - selection doesn't work when you move mouse outside DataTemplate area (outside the text of the ListBoxItem). I've resolved the problem by adding MouseMove event handler to ItemContainerStyle instead of DataTemplate.

Because MouseLeftButtonDown event doesn't fire for ListBox, I've added MouseLeftButtonDown event handler to ItemContainerStyle, too.

<Style x:Key="DropDownListBoxItemStyle" TargetType="ListBoxItem">
<Setter Property="Template">
<ControlTemplate TargetType="ListBoxItem">
<Grid MouseMove="Grid_MouseMove" MouseLeftButtonDown="Grid_MouseLeftButtonDown">

private void Grid_MouseMove(object sender, MouseEventArgs e)
Grid grd = sender as Grid;
this.DropDownListBox.SelectedItem = grd.DataContext;

Friday, September 5, 2008

Silverlight Tip 1#: How to find the absolute position of any control ?

For the past few weeks I've been working on Silverlight project, a prototype business application. So I'm going to write some posts about resolving practical problems with Silverlight 2.

I've written custom control with popup like combobox or listbox (see below).

<StackPanel x:Name="LayoutRoot" Height="Auto">
<TextBox x:Name="DropDownTextBox" />
<Popup x:Name="DropDownListPopUp">
<ListBox x:Name="DropDownListBox"
Style="{StaticResource DropDownListBoxStyle}"
ItemContainerStyle="{StaticResource DropDownListBoxItemStyle}"
ItemTemplate="{StaticResource DropDownDataTemplate}"

How to display popup directly below the textbox? In order to do this you must get absolute position of the control on form:

GeneralTransform gt = this.TransformToVisual(Application.Current.RootVisual as UIElement);
Point offset = gt.Transform(new Point(0, 0));

and set VerticalOffset and HorizontalOffset properties of popup:

DropDownListPopUp.VerticalOffset = offset.Y + this.DropDownTextBox.ActualHeight;
DropDownListPopUp.HorizontalOffset = offset.X;

Finally, you display popup:

DropDownListPopUp.IsOpen = true;

Thursday, August 7, 2008

Silverlight - some useful links (3)

Some information - 2.0.30523.6 vs 2.0.30523.8 (2 versions of SL2 Beta 2 runtime), - Silverlight roadmap questions (SL 2 RTM - summer 2008), - Silverlight for Mobile roadmap questions (beta - fall 2008, RTM - Q1 2009) - Silverlight 2 beta 2 installation fails on Windows 2000, - Firefox 3 and Silverlight - Where is Isolated Storage for Silverlight actually stored? - IsolatedStorage on non MS platforms (eg OSX), - Security in Silverlight - Beta 2 Event Bubbling - Detailed Overview of Silverlight 2 Beta 2 Web Service Features - Dropdown control - Dynamic Languages

Deep Zoom - Dynamically add new images to Deep Zoom collection? - Is there a Deep Zoom API? - Animations in Deep Zoom - MultiScaleImage background color - MultiScaleImage Pan & Zoom in one operation - Deep Zoom only images

3rd Party Components - CSLA Light - Silverlight Blueprint for SharePoint - Rad Controls for Silverlight - AgDataGrid Suite - AgLayoutControl for Silverlight - Silverlight Menu (or ToolBar) and Outlook Style Navigation Bar - WebUI Studio.NET (WebAqua.NET ) - Visual WebGui - GOA WinForms - ComponentOne Studio® for Silverlight - NetAdvantage for Silverlight - Silverlight .NET Controls - Reusables - Silverlight Control Toolkit - agTweener - Silverlight Library - Silverlight Charts


Custom implementations , - Bringing a bit of HTML to Silverlight (HtmlTextBlock), - DockPanel - SlideShow - Right Clicks in Silverlight - Rich Text Editor for Silverlight 2

Tips & tricks - What happened to Control.InitializeFromXaml? - How to read the client regional settings... - WebBrowser hosting XAP and WPF interop - data service Vs wcf/ web service for binding to sql db, - Configuring server to host Silverlight content - How to tell a Silverlight assembly from a .NET Framework one? - How to Get an Images Dimensions in Silverlight - Silverlight Dynamic Languages in Visual Studio - Design tutorials - Creating a custom panel - Pixel snapping - How to tell the screen resolution from within a Silverlight app - Dynamic reflection using silverlight-2 , - Navigating between Xaml Pages - Pages in Silverlight , , - Threading - Performance issues.... too many images?? - Silverlight Desktop Application Launcher - Silverlight standalone exe application - Obfuscator for Silverlight - Silverlight Extensibility: The Calculator - Modal-Dialogs and MessageBox-Like behaviour, - Reducing xap size - Silverlight security / privacy - Photo Carousel - Silverlight 2 MultiScaleImage Mouse Wheel Zooming and Panning Edition - Focus issue - How to use ResourceDictionary in Silverlight ? - How to have localization follow browser language, - Ink deserialization in the server - Ink Division for Silverlight - Redirect user if Silverlight not installed - How to open a new browser window in code? - How can I get the current WindowsPrincipal? - Silverlight 2 and User Identity, - ASP.NET authentication in a webservice with silverlight - Best practices for protecting WCF - Call a silverlight application from another silverlight application - Hosting in WPF?,guid,7f8857dc-5f37-4a8a-bd35-fd4b624af45b.aspx - Webcam in Silverlight 2 - MacGyver style! - Play YouTube FLV Videos with Silverlight 2.0

Missing features - How to type vietnamese(unicode) in textbox control ?, - Calling REST service using HttpWebRequest with Basic Authentication - How to reference a .NET class library in silverlight 2.0, , , - Displaying A PDF Document Inside A Silverlight UserControl, - Silverlight Printing - How to call the COM in silverlight 2.0 - Automate Office applications from Silverlight - Decorator control missing - Multi pick in a listbox, Microphone & Camera Support in the future ? - Bluetooth Connection Via Silverlight - FTP Upload in sl2.0 Beta2

Latest books
Laurence Moroney Introducing Microsoft Silverlight 2.0 (first 3 chapters free)

Wednesday, August 6, 2008

Silverlight - some useful links (2)

UI Automation

Unit testing,guid,f2fc834b-704e-40ae-9684-44cfa8096bed.aspx - Unit Driven

Custom implementations , - 3D graphics - Navigation Framework - XPS reader for Silverlight! - Silverlight 2 application that reads Word .docx files - Silverlight P2P Library - Silverlight TreeView, - RichTextEditor on SilverLight, - Viewbox control - Silverlight Progress Bar - Drawing Brush, - ComboBox - PasswordBox Control - Silveright FlyoutPanel - Effects and Transitions (framework) , , - Innerglow, Shadow, Glow Effects - Watermarkcontrol for Silverlight 2 Beta 2 - FlickrViewr Using DevDave’s AnimatingWrapPanel

Tips & tricks - Images with ResourceManager - How to Right Click on a Silverlight Application - Button Access Key - Problem with Focus and KeyDown, KeyUp Events, - Saving a file to the local disk, - Theming and Skinning (dynamic!), - Vista Gadgets , - Html page in Silverlight area - Customizing Mouse Pointer in Silverlight 2 beta 2 - How to implement LayoutTransform in Silverlight? - Problem while saving ink presenter content to png image - How to capture the size of your browser when it is resized - How to Set Browser Cookies

Missing features - Silverlight 2.0 missing features , - Silverlight and 3D - Triggers in Blend 2.5 June CTP - Capturing Function Keys (F5, F3, F1) - Semaphore? - Ink and Image - Xps Documents in silverlight - Tiling Bitmaps in an ImageBrush

Cool websites

Tuesday, August 5, 2008

My photo gallery with new Deep Zoom Composer!

Microsoft released new version of Deep Zoom Composer for Silverlight 2 Beta 2 on 1st August. Because of the issues with new functionality, an updated preview have been released on 3rd August (2 days later!)

The major new features include Panoramic Stitching and PhotoZoom Upload.

New Deep Zoom Composer integrates with the Live Labs PhotoZoom service: You can simply publish your image galleries with Deep Zoom on the Internet. I uploaded my photo album to PhotoZoom -;) My puzzle: how many photos can you find in main photo? (look at the beer can!)

The application now allows you to stitch similar images using technology from Microsoft Research's Interactive Visual Group.

More details about new Deep Zoom Composer:

Wednesday, July 30, 2008

Silverlight for Mobile

Some information about Silverlight for Mobile:

Current status: You cannot write a silverlight application for Mobile, because it is not in public beta yet -:(

Silverlight 1.0 for mobile CTP Q2CY 08
Silverlight 1.0 for mobile RTW Q4CY 08
Silverlight 2 for mobile CTP Q4CY 08
Silverlight 2 for Mobile RTW Q2CY 09

Supported systems:
Microsoft: Windows 6 Mobile Standard and Professional
Nokia: Symbian OS (Nokia S40, S60, internet tables)

Links: - some information + 2 interesting video presentations
(f.e gesture input device, carousel menu demo) - John L Scott's vision of Mobility and use of Silverlight - Nokia to bring Microsoft Silverlight powered experiences to millions of mobile users - Silverlight Mobile Application - How can I write a silverlight application for Mobile ? - Future: Silverlight2 and Windows Mobile