Unit testing is a tricky beast. As with all unit tests it is important to abstract any dependencies – so in the case of EF it’s the data persistence source. This must be handled carefully because EF creates a container that performs the interaction with the data source. Abstracting that container (via mocking or stubbing)... Continue Reading →
Silverlight Deferred / Delayed Selected Date Picker
When implementing a date picker that is used to fetch some ‘details’ based on the selected date, the chances are that you don’t want to begin fetching the ‘details’ immediately. If you did, and made a rapid change to the SelectedDate (maybe holding down an arrow key), the asynchronous fetch will be repeated a large... Continue Reading →
Regex hints #1
I love the power of regular expressions to do highly repetitive work for me, but I don’t use them frequently enough to remember the exacting intricacies of the syntax. Time for a series of posts with examples that have worked for me. First up, is the conversion of standard properties to notification properties. This can... Continue Reading →
Silverlight Commands – Data grid row selected
following on from http://thoughtjelly.blogspot.com/2009/09/silverlight-prism-commands-textchanged.html and in response to John Papa’s PDC talk http://johnpapa.net/silverlight/mvvm-and-prism-demo-for-pdc09-silverlight-session. Another highly useful command behaviour is for DataGridRowSelected. This also gets over the issues described here and here. The code (as written by John Papa) is: public class DataGridRowSelectedCommandBehavior : CommandBehaviorBase{public DataGridRowSelectedCommandBehavior(DataGrid selectableObject): base(selectableObject){selectableObject.SelectionChanged += OnSelectionChanged;}private void OnSelectionChanged(object sender, SelectionChangedEventArgs e){this.CommandParameter =... Continue Reading →
Data-binding Radio Buttons in Silverlight to Enum
In Silverlight there is no Enum.Getvalue() method, so there is not out-of-the box way of databinding a radio buttongroup to an enumerable value in a viewmodel. Step forward converters. using System;using System.Windows.Data;namespace YourNamespace{ public class EnumBoolConverter : IValueConverter{ #region Methods public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture){ if (value == null ||... Continue Reading →
Date issues in Silverlight
Seeing some strange date behaviours in SL UI components. My local culture is UK but we keep seeing US dates popping up “here and there”. Have tried setting the Language= “en-GB” in the upper most control, also setting the thread culture is not effecting across the app. Going to have to get help on this... Continue Reading →
Restyling Transitions in the Silverlight Toolkit TransitioningContentControl
(This post extends my example for using cross project merged dictionaries in Silverlight) I’m a developer, not a designer and as such using Expression Blend doesn’t feel natural and makes me feel dirty… However I had to bite the bullet to ease the restyling of the transition animation in the Toolkit TransitioningContentControl. NOTE: At time... Continue Reading →
Cross Project MergedDictionaries in Silverlight
Todd Miranda has posted a video on the use of merged dictionaries on the Learning portal of Silverlight.net (find it here). This video explains the concepts of MergedDictionaries in a very long winded way. IMHO people investigating MergedDictionaries will already know how to layout a grid, and play some simple controls, so the first 8m... Continue Reading →
Walking the XAML VisualTree to find a parent of type
To find a parent item of type T, you can use the following helper class: This can then be utilised as follows: Grid item = ((DependencyObject)childObject).FindParentOfType(); This was particularly useful when wanting to locate an invalid control from a ValidationSummary in silverlight, that was nested in an accordian panel: BIG shout out goes to Jedi... Continue Reading →
.NET Debugging and Stack Trace
When debugging enable the stack trace view to see where code has been triggered from. This is particularly useful for figuring out where events have been triggered from (delegation of event handlers from multiple places etc):