Since today XamlResource.com is officially in beta. Its purpose is to create a platform to find and share resources for Silverlight and WPF, resources in the form of Xaml. Have a look around and if you run into issues, please let us know at email@example.com.
In Beta 1 only a few of the final categories are supported:
- Colors; Resources of type SolidColorBrush
- Gradients; Resources of type GradientBrush
- Color sets; 2 to 5 resources of type SolidColorBrush
- Vectors; Resources of type StreamGeometry
This list will be extended with Styles, Themes, Templates and Shaders.
- Adding tags and searching by them.
- Access to the site from within Expression Blend
- Client side validation of entered xaml using Silverlight
- Automatic generation of preview image
- Download multiple resources at once in one ResourceDictionary
- An rss feed for news items
To keep up to date, follow us at http://twitter.com/XamlResource
This is the first in a series of small articles about what is new in Silverlight 4 and Expression Blend 4. The series is build around a open source demo application SilverAmp which is available on http://SilverAmp.CodePlex.com.
MVVM Project and Item Templates
Expression Blend has got a new project template to get started with a Model-View-ViewModel project easily. The template provides you with a View and a ViewModel bound together. It also adds the ViewModel to the SampleData of your project. It is available for both Silverlight and Wpf.
The solution now contains several folders:
- SampleData; which contains a data to show in Blend
- ViewModels; starts with one file, MainViewModel.cs
- Views; containing MainView.xaml with codebehind used for binding with the MainViewModel class.
- and your regular App.xaml and MainPage.xaml
The MainViewModel class contains a sample property and a sample method. Both the property and the method are used in the MainView control. The MainView control is a regular UserControl and is placed in the MainPage.
You can continue on building your applicaition by adding your own properties and methods to the ViewModel and adding controls to the View.
Adding Views with ViewModels is very easy too. The guys at Microsoft where nice enough to add a new Item template too: a UserControl with ViewModel. If you add this new item to the root of your solution it will add the .xaml file to the views folder and a .cs file to the ViewModels folder.
The databound Application project type is a great to get your MVVM based project started. It also functions a great source of information about how to connect it all together.
A few days ago I wanted to monitor all routed events fired in my application. Because I am running an XBAP application inside a browser windows, Snoop wasn’t very helpful (it usually is). Because all routed events are basically the same, you can handle them all with one singe event handler. Using the EventManger it is possible to get all routed events and register a class handler for every one of them.
The code below is a stripped down version of the code I’ve got implemented. When loaded, it gets all events. Than it loops to them and assigns a handler to them. It writes every event that is caught to the console. If you are using commands, you may way to filter them out, because very often the CanExecute and PreviewCanExecute events are raised on every command registered.
public partial class myUserControl: UserControl
Loaded += myUserControlLoaded
void myUserControlLoaded(object sender, RoutedEventArgs e)
var events = EventManager.GetRoutedEvents();
foreach (var routedEvent in events)
routedEvent, new RoutedEventHandler(handler));
internal static void handler(object sender, RoutedEventArgs e)
Console.WriteLine(e.OriginalSource + "=>" + e.RoutedEvent);