CoreCLR's Blog

Display a messagebox from the ViewModel using Prism’s InteractionRequests

Posted by coreclr on January 5, 2011

Prism has a nice feature called InteractionRequests. We can use this when the view-model needs to initiate an interaction, like displaying a messagebox.

Below is a simple example:

XAML:

In XAML I define the PopupChildWindowAction to display the dialog to the user.  The visuals of this dialog is defined in the SaveWindowsTemplate.
The magic here is the InteractionRequestTrigger from Prism. I set the SourceObject to the SaveRequest that is defined in the ViewModel.

SaveRequest is a InteractionRequest that define a Raise method, that we can use to raise the event.

I then use a interaction trigger to call the Cancel method in the viewmodel.  See Preview post.

ViewModel:

And the result look like this:

Posted in .NET, Silverlight | Leave a Comment »

Using interaction triggers in MVVM

Posted by coreclr on January 5, 2011

Commands are ofter to limited when using the MVVM pattern. Instead we can use interaction triggers.

Here is a simple example of handling the MouseEnter event for a button in a viewModel.

XAML:

ViewModel:

The key point here is the CallMethodAction object. CallMethodAction is a TriggerAction defined in the Microsoft.Expression.Interactivity.Core namespace. In this example I set TargetObject to the DataContext (the viewModel) and MethodName to the method we want to call in the ViewModel.

If you need to send parameters to the method, you just expose those as properties in the viewModel and use standard DataBinding.

Remember to reference Microsoft.Expression.Interactions.dll

Posted in .NET, Silverlight | Leave a Comment »

Events i CNUG

Posted by coreclr on December 19, 2010

Vi har i foråret 2011 planlagt nogle rigtig spændende events i CNUG.

I januar snakker Anders Lybecker om Lucene.Net. I januar får vi også besøg af Marcus Wendt & Martin Jensen som snakker om Composite C1.

Til februar snakker Joachim Lykke Andersen om Code First i EF4 og til marts snakker Kenneth Auchenberg om jQuery. Til april kommer Brian Rasmussen og Richard Flamsholt og snakker om Performance og Profiling i .NET.

Du kan følge CNUG på linkedin og på CNUG.dk. Alle vores events bliver oprettet på eventbrite og du kan abonnere på vores RSS feed her.

Posted in Uncategorized | Leave a Comment »

10 Ways to Make the Most of Training

Posted by coreclr on December 17, 2010

Great post about making the most of training.

Posted in Uncategorized | Leave a Comment »

Integration Patterns Book

Posted by coreclr on December 16, 2010

This is a very usefull book (pdf) from patterns & practices.

Posted in Uncategorized | Leave a Comment »

Uncle Bob in Copenhagen

Posted by coreclr on December 16, 2010

Unique opportunity to get training from Robert C. Martin.
Read more here

Posted in Uncategorized | Leave a Comment »

Force VS to garbage collect

Posted by coreclr on December 16, 2010

Ctrl-Alt-Shift-F12, twice

Very nice.

http://blogs.msdn.com/b/camerons/archive/2010/12/15/force-vs-to-garbage-collect.aspx

Posted in Uncategorized | Leave a Comment »

On Architecture

Posted by coreclr on December 12, 2010

If you are interested in software architecture, you might want to check out IEEE’s “On Architecture” Podcast with Grady Booch:
http://www.computer.org/portal/web/computingnow/onarchitecture

Posted in Uncategorized | Leave a Comment »

Juval Löwy’s Architect’s Master Class in Copenhagen

Posted by coreclr on December 4, 2010

Juval Löwy is teaching his Architect’s Master Class in Copenhagen from march 7 to marts 11.
Read more here http://www.teknologisk.dk/uddannelser/k88581?cms.query=masterclass

Posted in Uncategorized | Leave a Comment »

Executing Unit Tests on the Build server only

Posted by coreclr on November 18, 2010

We often have some Unit Tests/Integration Tests that we only want to execute when the tests are running on the TFS build server.
One solution is to put these tests in a separate solution, but this is annoying when doing refactoring. Having a separate solution is also a bad choice when we want to see our total code coverage results.
Another solution is to use the Test List feature in Visual Studio, but these Test Lists are just pure pain!

I would like to put an attribute on the TestMethod instead. As far as I know, this is not possible today.

So currently we have an environment variable on the build server, and then we use this method from our tests:

public static class TestUtils
{
	public static bool IsTestRunningOnBuildServer()
	{
		if (Environment.GetEnvironmentVariable("IS_TFS_SERVER", EnvironmentVariableTarget.Machine) != null)
		{
			return true;
		}
	   return false;
	}
}

Very simple, but it works.

Another solution is to use Test Categories in TFS2010:

http://www.edsquared.com/2009/09/25/Test+Categories+And+Running+A+Subset+Of+Tests+In+Team+Foundation+Server+2010.aspx

 

Posted in .NET | Tagged: | Leave a Comment »