ItemsControl with multiple DataTemplates for a viewmodel

You can create multiple ObservableCollections and then bind your ItemsSource to a CompositeCollection which joins those collections. Then in your XAML you can create different DataTemplates for the respective types using the DataType property which like styles gets automatically applied if it is placed in the resources. (You can also create the composite in XAML … Read more

Display GIF in a WP7 application with Silverlight

In fact, it’s working, but it lacks some documentation. After some troubles, here’s how to use it : reference ImageTools reference ImageTools.Controls reference ImageTools.IO.Gif Add namespace in xaml : xmlns:imagetools=”clr-namespace:ImageTools.Controls;assembly=ImageTools.Controls” And resources : <phone:PhoneApplicationPage.Resources> <imagetools:ImageConverter x:Key=”ImageConverter” /> </phone:PhoneApplicationPage.Resources> Then use the control with the converter : <imagetools:AnimatedImage Source=”{Binding ImageSource, Converter={StaticResource ImageConverter}}” /> Your ImageSource should … Read more

Could not find an implementation of the query pattern

Is the tblPersoon implementing IEnumerable<T>? You may need to do it using: var query = (from p in tblPersoon.Cast<Person>() select p).Single(); This kind of error (Could not find an implementation of the query pattern) usually occurs when: You are missing LINQ namespace usage (using System.Linq) Type you are querying does not implement IEnumerable<T> Edit: Apart … Read more

“UpdateSourceTrigger=PropertyChanged” equivalent for a Windows Phone 7 TextBox

Silverlight for WP7 does not support the syntax you’ve listed. Do the following instead: <TextBox TextChanged=”OnTextBoxTextChanged” Text=”{Binding MyText, Mode=TwoWay, UpdateSourceTrigger=Explicit}” /> UpdateSourceTrigger = Explicit is a smart bonus here. What is it? Explicit: Updates the binding source only when you call the UpdateSource method. It saves you one extra binding set when the user leaves … Read more