Silverlight.FX and Silverlight Store Sample App

About the Silverlight.FX project and the latest sample addition...

I've got a project page finally up for Silverlight.FX, so it can be easily linked to rather than some arbitrary blog post of mine that alludes to it, and is a one-stop spot for the latest build, and relevant links and pointers to samples. As always, the full source code for the sample along with source code for the framework is available. For those who'd like to track progress as it happens, you can watch it on the associated GitHub repository as well. You can even fork and experiment if you'd like… I would definitely love to hear what you think about the project. Eventually I might set up something dedicated for facilitating discussion if there is interest.

While Silverlight.FX is something I use to prototype ideas into more tangible building blocks, some of which may eventually get incorporated into the platform, I am building the framework with concrete patterns and app scenarios in mind, so it is useful in its own right. Here is my one-line description of what Silverlight.FX is:

A small and lean framework that facilitates more structured and more declarative app development (eg. separation of view/code, effects, behaviors etc.) using Silverlight.

I've built a small collection of sample applications to highlight the features and concepts. Nothing beats app-building to help flesh things out. One of the applications is Silverlight Store - this is a small little application that allows you to search the Amazon catalog, as well as check out the latest deals and bargains, add them to your cart, and then do a checkout (for real if you go all the way). Below is a screenshot.

This sample has pretty much no code-behind. Everything is done either declaratively or with a view model (aka presenation model).
In addition it demonstrates:

  • View Model pattern
  • Simple/minimal IoC container
  • Declarative Effects and Transitions
  • Behaviors, actions and triggers as well as commanding
  • ListView and DetailsView controls
  • Animated Layouts (TilePanel)
  • TemplatePanel (like asp.net master pages)
  • Dialogs

When you run the sample, you'll want to do a few searches, and run it to experience the overall interaction model. The look and feel of the application was inspired by the original Flex Store sample app, but has a bit more color. :-)

Over time I plan to keep updating this sample to demonstrate building declarative data sources, navigation, theming, and MVC, as well as ability to write unit tests for the view model, and eventually update it to add some new Silverlight 3 features as well. Along the way, I also plan on doing a series of conceptual blog posts covering both ideas and features, and using snippets of this sample to illustrate the point.

This is just one of the samples - some other notable ones I've shared in the past are described in the blog posts on effects and transitions and the View Model pattern.


[ Tags: | | ]
Posted on Wednesday, 3/4/2009 @ 2:35 PM | #Silverlight


Comments

25 comments have been posted.

Mehfuz

Posted on 3/4/2009 @ 7:00 PM
This looks cool!!

vikram

Posted on 3/4/2009 @ 9:44 PM
Great as always

Salman Farsi

Posted on 3/4/2009 @ 10:55 PM
Good example, I was clone the same Flex Store in WPF with little bit more functionalities, as yours. It seems a greate project.
Hope that in future we have a powerful framework for Silverlight Applications.

Steve Gentile

Posted on 3/5/2009 @ 5:46 AM
Just a 'recommendation' - but your framework with it's behaviors, etc... seems to fill a gap in the Prism framework.

Any chance you'd consider some sort of install path and setup instructions for using your framework in conjunction with Prism?

ie. they are lagging behind in 'commanding/messaging' (see Caliburn) - and yet, I think your framework has some parts that would help provide some glue here.

At this point, imo , the ability to mix and match the different frameworks would be nice :)

Thanks

Nikhil Kothari

Posted on 3/5/2009 @ 7:33 AM
Steve - shouldn't mix and match, and install be easy and possible already? Just add a reference to the assembly in your xap, and you're done. Let me know if there is something specific in terms of scenario you're looking for.

KierenH

Posted on 3/6/2009 @ 9:35 PM
Awesome!
When I demo these sorts of websites in a corporate environment I often hear 'that is unnecessary'... the store is very usable, and the population is really getting in touch with technology. There is a perception that they take longer to develop then traditional win forms looking apps, when the reality is they should be faster.
What I like about this project is the framework for building effects. I envision that it could work just like jQuery, where we could browse and download pre-rolled effects. This could help with productivity :)

How could you make this demo even better?
Integration with windows workflow
Validation controls/pattern

Cheers

Steve Gentile

Posted on 3/7/2009 @ 6:19 AM
I agree to the jQuery analogy, this library is fantastic.

It would be nice to create a Silverlight.FX repository Nikhil, where others can contribute effects to the project, perhaps a Silverlight.FX Contrib :)

Nikhil Kothari

Posted on 3/7/2009 @ 9:00 AM
@KierenH - Thanks!
I have some ideas for workflow and Silverlight.FX - over time.
On the validation front, I know I want to do some additional stuff in Silverlight.FX on top of SL3 when that comes out... so also stay tuned on the front.
Both are very valid suggestions.

@Steve Gentile -
There is a GitHub repository for Silverlight.FX. You can fork that add to it. Or the contrib idea sounds interesting as well. Does someone want to lead/start that project... ideally on GitHub? Now that I mention it, I think there is one: http://github.com/Dimebrain/silverlightfx.contrib/tree/master
Would be interesting if folks can get together on this...

Michael Washington

Posted on 3/7/2009 @ 10:55 AM
This i sgreat. Vey good usability and most importantly speed. For a Intranet app, something like this is superior to a standard website. Of course this app is a "store" and that does not say "Intranet" so perhaps the next example can be a "corporate intranet app"?

KierenH

Posted on 3/7/2009 @ 6:33 PM
Why SL3? Atm, Silverlight platform is great for presentation of data, but data entry support seems to be lacking.

Wish I could be more involved with steering Silverlight.FX... I implemented the framework at my last place of work, but moved to a new role recently where I'm developing an Asp.net MVC web app with Ajax/jQuery... the web app is targetting the Apple iPhone, if the iPhone was a supported platform, then I'd be on board :) We have a requirement for duplex Wcf, so Silverlight would be a buy there. Atm we're using the Comet paradigm to simulate two-way connections.

I've read that MS plans to support SL on any platform that has an sdk? A little more light on this subject would be great.

Senthil Kumar

Posted on 3/8/2009 @ 10:39 PM
This Looks Really cool

Alexandre Roba

Posted on 3/10/2009 @ 4:49 AM
I'm giving it a try. Looks really handy so far.

I have an issue that you may be able to help me on.

I have created a view, and assign a viewmodel to it.

On this view I have couple of TemplatePanel.

On those Template I have couple of controls binded to some of my ViewModel properties.

For regular controls it all works wel... The get of my modelview properties are called.

If I try to use a more complex control like the Tree view from the tool kit or the Tree view from telerik. the get method of the binded property is neger called :(....

Any idea on this?

Here is a code snippet:

<fxui:TemplatePanel Style="{StaticResource sectionStyle}" Grid.Column="1" Grid.Row="2" Grid.RowSpan="3">
<TextBlock Text="{Binding Catalogentries}" fxui:TemplatePanel.ContentName="header"/> <!-- Works! Get_NavigationEntries is called -->
<telerikNavigation:RadTreeView x:Name="trvCatalog" ItemsSource="{Binding NavigationEntries}" SelectionMode="Single"> <!-- Nothing happen here! Get_NavigationEntries is not called -->
<telerikNavigation:RadTreeView.ItemTemplate>
<Controls:HierarchicalDataTemplate ItemsSource="{Binding CatalogEntries}">
<TextBlock Text="{Binding Name}" Tag="{Binding MethodName}"/>
</Controls:HierarchicalDataTemplate>
</telerikNavigation:RadTreeView.ItemTemplate>
</telerikNavigation:RadTreeView>
</fxui:TemplatePanel>

alexandre Roba

Posted on 3/10/2009 @ 5:13 AM
Find out where the problem was coming from.

I had not specified any fxui:TemplatePanel.ContentName="body" on the treeview. so the control was not rendered...

I will keep investigate the framework but I'm starting to really enjoy it. :)

thankx

Nikhil Kothari

Posted on 3/10/2009 @ 8:23 AM
@Alexandre - I just posted on TemplatePanel as well.
http://www.nikhilk.net/Silverlight-TemplatePanel.aspx

I suppose TemplatePanel could catch and throw an error about something in its content list that doesn't have a ContentName or doesn't have a ContentName that matches a ContentPresenter... for these kinds of issues...

Anyway, great to hear you're enjoying the framework.

Emil Stoychev

Posted on 3/20/2009 @ 1:44 AM
I found SilverlightFX a great framework that simplifies application development and helps for writing much cleaner code/markup.
One thing I miss, however, is the lack of documentation. The only way I can learn about the framework is from the blog posts and the provided samples and sources. Yes, that is quite a lot actually, but still not enough to get a deeper understandings. Learning the things this way is also a time-consuming task. As a suggestions a would recommend writing a documentation that explains how the different parts of the framework can be used.

I currently use SilverlightFX in an on-going Silverlight project and it really adds a great baseline you can build on.
One thing I struggled with is the ShowForm action. I digg into how it is used in the AmazonStore sample and it is quite straight forward, but I couldn't get it running. Basically what I have is exactly the same as in the AmazonStore sample:
<TextBlock ...>
<fxui:Interaction.Triggers>
<fxui:MouseTrigger>
<fxaction:ShowForm FormType="MyForm" />
</fxui:MouseTrigger>
</fxui:Interaction.Triggers>
</TextBlock>

where MyForm(tried also with the full name) is fxui:Form with a fxui:TemplatePanel

Click on the TextBlock fires nothing. Nothing happens at all. I don't have an idea how I can debug that also.

I'll appreciate if anyone can help on that.

Thank you.

Nikhil Kothari

Posted on 3/20/2009 @ 10:08 PM
@Emil - I hear you on the documentation. Its hard to both develop the framework, the samples and get a doc effort going as well. I wish I had the luxury of a UE team :-)

On your Form issue, does your Form have a parameterless public ctor? Can you turn on the debugger feature to break on when an exception is thrown to see where the error is coming from? You might want to try and link to the debug Silverlight.FX assembly along with pdb... this is why I have the debug builds and sources included in the zip.

Emil Stoychev

Posted on 3/22/2009 @ 11:59 PM
@Nikhil - about the documentation - yes, I can imagine that.

I posted another comment here on the Form issue, but I don't see it now. It may have been spam-scored or something. What I wrote in it was that once I change my app to inherit from XApplication (not from Application) the issue was gone. But I'm curious why this is happening. Is there any particular reason? Everything else I'm using from Silverlight.FX framework doesn't require that.

My Form have a parameterless public ctor. I already tried to debug it, but the debugger doesn't break on any exception (I have a reference to the debug dll). I uploaded a project that isolates my case - you might want to take a look at it. http://weblogs.asp.net/blogs/emilstoichev/SilverlightFXTests.zip
By just changing my app to inherit from XApplication the form starts working.

Jay

Posted on 3/25/2009 @ 12:53 PM
I'm guessing that like many Silverlight developers, I'm totally confused as to which framework to select going forward (FX, Caliburn, Prism, Ninject, or one of the dozens of samples explaining WVVM) if I'm starting out a new application with a multi-year lifespan and therefore SL3 compatibility is an important consideration.

Is it true that FX is a good choice if my requirements are (in order of importance):

- SL3 compatiblity
- small footprint
- dependency injection
- navigation
- effects
- themes (are FX themes compatible with SL Toolbox themes BTW?)

Perhaps another way of asking this is: Which framework will be most easily subsumed by SL3?

Nikhil Kothari

Posted on 3/25/2009 @ 9:04 PM
@Emil
Form does have a dependency on XApplication. In SL2, popups have to be parented, and XApplication sets up a top-level screen visual that contains the top-level window, and any Forms you show.
In SL3, there are ways to introduce this type of functionality without introducing a derived application type, so I will switch to that as I make the move to using SL3 for Silverlight.FX.

@Jay - Silverlight.FX will definitely move on to SL3.
There are lots of compelling features and capabilities to pick up. All of those things you mention are important to Silverlight.FX.
On the themes question, Silverlight.FX offers a way to author themes and apply themes - but some of that will change to using SL3's merged resource dictionaries. At that point Silverlight.FX will probably offer a way to select a theme dynamically rather than author themes.

Aurum

Posted on 4/20/2009 @ 6:36 AM
Hello,
I found a strange binding behavior in the SilverlightFX. It's maybe a bug or maybe I don't understand its philosophy well. Would you check this small application to demonstrate this behavior: http://aurum.hu/prog/SilverlightApplication1.zip
It contains two textboxes, one of them is binded to a data source class, another one is binded to a property of the model. Take a break point to the setter of the property of the model then try to append only one char to the textbox is binded to the property of the model. If you change only one char and click out from the textbox or use the TAB key, the change will be binded and set into the property. In theory, but in practise every second times only. So, if you change only one char on tht textbox, every second change will cause binding on the model. The another textbox binded to the data source class works correctly, this behavior related to the Model only. If you change two or more chars, the binding works correctly.
This image demostrates this effect: http://aurum.hu/prog/bindingerror.png The textbox contains "ModelName12" but the textblock only "ModelName1", because the second change, the "2" didn't cause binding, the value didn't set back to the property of the model.

Ron Teblum

Posted on 4/24/2009 @ 10:18 AM
Hello Sir,

We are a bizspark partner of Microsofts and we are developing all our sites using silverlight technology. We have some questions regarding your application. Is there a contact phone number that we could possibly use to help us integrate your amazon example with what we are doing. This would be a great help.

Thanks
Ronald Teblum

Asheesh Soni

Posted on 5/22/2009 @ 1:53 AM
Silverlight.FX Rocks!

Wouldn't it be great if your Model class inherited from DependencyObject so we could have custom DependencyProperties in the view model?

I need your help in implementing an aggregate predicate filter on the list of products so we could have multiple filter criterias (predicates).
For simplicity, lets say we want to filter by price range (with a lower price slider and an upper price slider).

How should I go about it?

I tried a couple of ways like:
1. Having multiple converters (lets say lowerPriceConverter, upperPriceConverter etc.) and binding the 2 sliders and the list to the ProductFilter. But obviously you only have access to one filter at a time, so this doesn't work.

2. So I tried adding the properties (like int lowerPriceRange, int upperPriceRange etc.) to the Main Window View Model and binding the sliders to these properties. But these bindings don't work.... probably because they are just normal CLR properties instead of DependencyProperty

3. So I created the following class (yeah its house search not product):

public sealed class HouseFilter : DependencyObject
{
public static readonly DependencyProperty HouseFilterPredicateProperty;
public static readonly DependencyProperty PriceRangeLowerProperty;
public static readonly DependencyProperty PriceRangeUpperProperty;

public IPredicate<object> HouseFilterPredicate
{
set { SetValue(HouseFilterPredicateProperty, value); }
get { return (IPredicate<object>)GetValue(HouseFilterPredicateProperty); }
}
public int PriceRangeLower
{
set { SetValue(PriceRangeLowerProperty, value); }
get { return (int)GetValue(PriceRangeLowerProperty); }
}
public int PriceRangeUpper
{
set { SetValue(PriceRangeUpperProperty, value); }
get { return (int)GetValue(PriceRangeUpperProperty); }
}

static HouseFilter()
{
HouseFilterPredicateProperty = DependencyProperty.Register("HouseFilterPredicate", typeof(IPredicate<object>), typeof(HouseFilter), null);
PriceRangeLowerProperty = DependencyProperty.Register("PriceRangeLower", typeof(int), typeof(HouseFilter), new PropertyMetadata(0, new PropertyChangedCallback(OnFilterChanged)));
PriceRangeUpperProperty = DependencyProperty.Register("PriceRangeUpper", typeof(int), typeof(HouseFilter), new PropertyMetadata(300000, new PropertyChangedCallback(OnFilterChanged)));
}

public HouseFilter()
{
}

private static void OnFilterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
HouseFilter h = (HouseFilter)d;
h.HouseFilterPredicate = new FilterPredicate(h.PriceRangeLower, h.PriceRangeUpper);
}

public class FilterPredicate : IPredicate<object>
{
private int PriceRangeLower;
private int PriceRangeUpper;

public FilterPredicate(int priceRangeLower, int priceRangeUpper)
{
PriceRangeLower = priceRangeLower;
PriceRangeUpper = priceRangeUpper;
}

public bool Filter(object item)
{
return ((House)item).Price >= PriceRangeLower && ((House)item).Price <= PriceRangeUpper;
}
}
}

The ViewModel has an instance of this HouseFilter class (called AggregateHouseFilter) and the Xaml sliders and List bind to AggregateHouseFilter.PriceRangeLower, AggregateHouseFilter.PriceRangeUpper and AggregateHouseFilter.HouseFilterPredicate

Everything works except that the List binding to the AggregateHouseFilter.HouseFilterPredicate never picks up the filter change.

Xaml for slider and ListView:

<fxui:XSlider Style="{StaticResource slider}" Width="100" Minimum="0" Maximum="300000"
Value="{Binding AggregateHouseFilter.PriceRangeUpper, Mode=TwoWay}" />

<fxui:ListView Style="{StaticResource houseList}" fxui:TemplatePanel.ContentName="body" DataSource="{Binding HouseCatalog.Houses}"
ItemFilter="{Binding AggregateHouseFilter.HouseFilterPredicate}" ItemSort="{Binding HouseSort}">

Any ideas how to implement this sort of composite predicate search with Silverlight.FX?

Thanks

Roudi

Posted on 9/9/2009 @ 3:35 AM
Hi All,

Nice application.. but i need your help in one thing.
Can you please Nikhil tell me how to connect this application to my data base, please tell me whether i have to use certain function names for webservice and
from where the data is retrieved.
Im using SQL Server 2005 or 2008

Please any one who know the answer, i appreciate your help.

Cheers,
Roudi

Ozz

Posted on 5/18/2010 @ 2:35 PM
The Sample loads but no products show up. I clicked all the buttons, did a search, and nada. Im running SL4 and using Firefox and IE. Looks nice tho!

Gary

Posted on 3/14/2011 @ 11:24 AM
When will there be Silverlight 4 support? The most resent build I see so for is targeting Silverlight 3.
Post your comment and continue the discussion.