Breaking changes in WAF 1.0.0.8

Coordinator
Dec 28, 2009 at 12:50 PM

Unfortunately, it was necessary to introduce a few breaking changes in the WAF 1.0.0.8 release. This post should help you to adapt the changes in your code.

1. Renamed ViewModel<T>.View property to ViewCore and changed it from public to protected.

Old:

public class ShellViewModel : ViewModel<IShellView>
{
    public void Show()
    {
        View.Show();
    }
}

New:

public class ShellViewModel : ViewModel<IShellView>
{
    public void Show()
    {
        ViewCore.Show();
    }
}
 

2. ViewModel.View property exposes now only object and not IView

Won’t work anymore::

shellViewModel.View.Show();

Better:

shellViewModel.Show();

Also possible but avoid it:

((IShellView)shellViewModel.View).Show();
 

3. UnitTesting: Renamed the AssertUtil class to AssertHelper.

Use “search and replace” to search for AssertUtil and replace it with AssertHelper.
 

4. UnitTesting: Removed the DispatcherUtil class because the DoEvents method is not necessary anymore.

You shouldn’t use the DoEvents method. But when you really need it then you can create your own helper class. Here is the source code:

/// <summary>
/// This class provides helper methods for the WPF Dispatcher.
/// </summary>
public static class DispatcherHelper
{
    /// <summary>
    /// Execute the event queue of the dispatcher.
    /// </summary>
    public static void DoEvents()
    {
        DispatcherFrame frame = new DispatcherFrame();
        Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
            new DispatcherOperationCallback(ExitFrame), frame);
        Dispatcher.PushFrame(frame);
    }
 
    private static object ExitFrame(object frame)
    {
        ((DispatcherFrame)frame).Continue = false;
        return null;
    }
}