NotificationWindow – Silverlight 4

A new addition to Silverlight 4 is the NotificationWindow.  This type of window enables you to show a System notification much like when you receive an Outlook new mail notification or a Growl notification in OSX. Since it operates like a system message, this feature is only available in Out of Browser (OOB) scenarios.

This example shows how to instantiate a NotificationWindow, with the resulting application like the below screenshot.

image 

Code

And now for the code. The items to note:

  • In the Tick event check to see if the application is running in OOB.
  • If yes, then instantiate a NotificationWindow object.
  • Set the Content (this could be as simple as a TextBlock or a custom UserControl)
  • To show the Notification, call the Show method specifying, in milliseconds, the duration of the Notification.

image

 

image

Q: Can I show multiple notifications?
A: No, there isn’t a queue.

Q: Can the user interact with the NotificationWindow?
A: Yes, but only mouse support.

Q: What is the size of the NotificationWindow?
A: 400×100 (btw, I love Pixus)

image

 

Q: Can the NotificationWindow be customized?

A: Yes, below is a screenshot of the notification window using a custom UserControl instead of a TextBlock like the above example.

image

Silverlight 4 – new features

When Silverlight 3 debuted at MIX09, there were a number of places to find information about the new features, so better than others.  Unfortunately I never remembered the sites and always relied on Google to produce the site for me.  This time will be different; this post will serve as my place for SL4 info.

image
http://silverlight.net/getstarted/silverlight-4-beta/

 

image 
http://blogs.silverlight.net/blogs/jesseliberty/

 

image
http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx

 

image 
http://geekswithblogs.net/WynApseTechnicalMusings/archive/2009/11/18/136394.aspx

 

image
http://wildermuth.com/2009/11/18/Silverlight_4_Beta_Announced!

Check if running in Out of Browser - Silverlight

As Silverlight increases its Out of Browser features it will become more important to detect if the application is running in or out of the browser.  This is the check:

image

This was a quick one.

Behavior driven development

A session that caught my eye from PDC was a session titled Behavior driven development vs Test driven development.  I don’t think this session had direct ties to Silverlight, however it made me think about Silverlight Behavior development.  Could this be a topic?

Lately I have been a big advocate about using behaviors for UI interactions when developing a Silverlight app.  Behaviors enable me to quickly develop a rich UI without much code and focus on functionality.

This is a quick thought, and more to come about it, but wanted to throw it out there.  In the meantime check out

http://www.85turns.com/2009/10/14/top-5-silverlight-behaviors/

Top 5 Silverlight Behaviors

Finding behaviors for Silverlight has become much easier with the Expression Community Gallery.  The goal is to have a central place for all things Expression.  It’s still young, but gaining steam.  Being a big fan of behaviors, I have compiled a list of my top 5 favorite Silverlight behaviors.   

5. TextboxEditMask

imagelink: http://gallery.expression.microsoft.com/en-us/CMEditMaskBehavior

For data input, there is nothing like a TextBox that handles all the formatting for you.  Jim Fisher has created a behavior that enables you to easily add a mask to a TextBox, ensuring your users aren’t entering garbage.  For more information, check out Jim’s post.

 

 

4. Resize Behavior

imagelink: http://gallery.expression.microsoft.com/en-us/ResizeBehavior

Blend has a built in behavior for dragging.  As a user, one of the first things I want to do after dragging an object is to resize it.  Alessio Galdy has created a behavior that does exactly this.  Take a look at the sample on the Gallery to see his feature rich resize behavior.

 

 

 

3. Swivel Behavior

imagelink: http://gallery.expression.microsoft.com/en-us/SwivelBehavior

Silverlight 3 introduced a number of features that many consider “eye candy” (pixel shaders, perspective 3d, animations easing).   John Papa uses the perspective 3d feature to create a swivel behavior.  This can be helpful if you, or your clients, need to conserve space.  Think about a menu with an overview and details section.  Simply create two views, attach this behavior, and one side you have the overview and the other are your details.

 

2. Mouse Wheel Scroll Behavior

imagelink: http://gallery.expression.microsoft.com/en-us/MouseWheelScroll

I can’t count the number of times I’ve gone to a Silverlight app and started using my mouse wheel to scroll through the ListBox, ScrollViewer, or ComboBox.  Along with not putting the Hand cursor on Buttons, this is my biggest pet peeve in Silverlight apps.  With Kelps’ behavior, you can easily add mouse wheel scrolling to scrollable areas.

 

 

 

 

1. Behaviors from MIX’09

imagelink: http://gallery.expression.microsoft.com/en-us/MIXBehaviorPack

These are the first set of behaviors you should download.  Posted by Peter Blois, of the Blend team, these behaviors include:

  • Media behaviors (Play, Pause, Rewind, and Stop)
  • Triggers, including an awesome MouseGestureTrigger and a StateChangedTrigger
  • Data behaviors – if using MVVM, these behaviors can save you a lot of time

Needless to say, this package is the real deal.

 

Honorable Mention - Multi-Touch Drag and Zoom Behaviors

link: http://gallery.expression.microsoft.com/en-us/MultiTouch

This is a relatively new behavior to the Gallery (by a new Silverlight MVP, Davide Zordan) and unfortunately I haven’t taken a look at it because it requires a multitouch screen, which I am lacking.  If you do, check it out.  Additionally, read Davide’s post on this behaviors implementation.

 

Best Behaviors not on the Expression Community Gallery – Physics Helper

image These set of behaviors enable you to quickly add physics to objects without having to dive into the world of a physics engine.  I highly recommend you check out “The Basics” video to get learn how to use the behaviors. 

Silverlight MVP

image

On October 1st I was awarded the Microsoft MVP for Silverlight.  I am very honored and excited about this.  The MVP program, taken from Tim Heuer’s post, “ is a recognition program that is in place to recognize and reward those individuals who have been identified by individuals (peers, Microsoft staff, etc.) as experts in their technology field and global contributors to the technology”

The other talented group of guys in this round of Silverlight MVP’s are (for the complete list of Silverlight MVP’s follow this link):

Talking about and working with Silverlight has been a dream come true.  It enables me to pursue my passion of creating experiences and not applications (more to come on that). 

There have been many people who have helped me in the MVP process; namely Glen Gordon, Jesse Liberty, Tim Heuer, John Papa, and Justin Angel.  Thank you, and I look forward to the upcoming year.

Silverlight tip – managing HTML

image

Problem: Silverlight 2 & Silverlight 3 do not support HTML, how can I remove the tags?

Solution: Although there are many solutions to this problem, the quickest and most frequently solution I use is a regular expression to remove HTML tags.  The most straightforward example I’ve found is from John Papa’s book Data Driven Services with Silverlight 2

// Remove HTML tags and empty newlines and spaces and leading spaces
string formattedValue = REgex.Replace(value as string, "<.*?>", "");
formattedValue = Regex.Replace(formattedValue, @"\n+\s+", "\n\n");
formattedValue = formattedValue.TrimStart(’ ‘);
fromattedValue = HttpUtility.HtmlDecode(formattedValue);
if(length > 0 && formattedValue.Length >= length)
  formattedvalue = formattedValue.Substring(0, length - 1);
return formattedValue;

Silverlight tip – Dynamic TextBlock

image

Problem: You need text to dynamically add elipses, "…",  to the end of a sentence.  The difficulty is how do you detect the actual length of the string.  All characters are not created the same.  Ten i’s != ten m’s.

Solution: Robby Ingebretsen at NerdPlusArt.com (and of Kaxaml fame) has a dynamic control that does just this.  http://blog.nerdplusart.com/archives/texttrimming-textblock-for-silverlight.

The solution is very Elegant.  Robby wraps a TextBlock in a Content control then manipulates the Text inside based on the size.  Best of all…he as post code and an example.  Thanks Robby.

Back to the basics

It’s been almost two years since I started this blog.  It mainly started out as a way for me to keep track of my learnings (unfortunately Evernote has taken that place).  There are a number of other sites that have similar information, but that’s the point of blogs to provide information to the community

Certainly I want to stay current and come out with latest and greatest but in doing so I’ve lost site point of my blog keep it simple and keep track of what I’ve learned.  So, the next few posts will be focused on keeping it simple.

Thanks for reading and helping make this blog great.

Changes – IQ, Turin, and more

image

Over the past six months I’ve had the amazing opportunity to work with a highly talented team (Mason Brown, Casey Britt, SmartyP, and many more) at IQ Interactive.  We’ve been working on an amazing, ground breaking, Silverlight application.  There wasn’t a stone unturned while developing.  Items such as Pixel Shaders, custom Panels, animations for purpose (as they should be), LINQ, dynamic loading of xap, Prism, and much more illustrate the breadth of the technology. I want to share the experience/application with you so badly but it will have to wait until the end of this month.

The biggest win over the past months is not the use of technology, but the team.  When I joined there was a large Silverlight project without any Silverlight knowledge.  Everyone rallied, designers were brought up to speed on Blend and Flash devs were put to work.  IQ now has a competent and competitive team of Silverlight developers/designers, and I am so happy to have been, and continue to be part of that. 

Over the next few month, and into the beginning of next year, I will be taking on a consultant role with IQ to ensure the project sails smoothly into launch and advice  with the direction of IQ’s Silverlight practice.  Doing this enables me to work on a number of key Silverlight projects in the media space in Turin, Italy.  Hopefully the jet lag wears off soon, because I’m ready to dig in, build awesome Silverlight projects, and most importantly build another team of kick ass Silverlight developers.

From Turin – ciao ciao