I've started using [Code Contracts](http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx) in all new code I'm writing, such as in a framework library I'm building to help bootstrap [IoC](http://en.wikipedia.org/wiki/Inversion_of_control), [O/RM](http://en.wikipedia.org/wiki/Object-relational_mapping), etc., in an ASP.NET MVC application. I've written a simple build script for this framework library that looks like the following:

```
@echo off
echo.
echo Cleaning build output (removing 'obj' and 'bin' folders)...
for /f "tokens=*" %%G in ('dir /b /ad /s bin') do rmdir /s /q "%%G"
for /f "tokens=*" %%G in ('dir /b /ad /s obj') do rmdir /s /q "%%G"
rmdir /s /q build
echo.
echo Starting the build...
call "%VS100COMNTOOLS%\vsvars32.bat"
msbuild Integration.build /target:Build
echo.
echo Done!
pause

```

This doesn't work. What I end up with in my `build` folder if I run this is, for whatever reason, assemblies that aren't fully rewritten by `ccrewrite` alongside `.pdb.original`, `.rewritten` and `.csproj.FileListAbsolute.txt` files that litter the output directory.

What does work is first building the solution in Visual Studio 2010, commenting out line 3 through 7 in the batch file and running it again. I then end up with properly rewritten assemblies and no `.pdb.original` nor `.rewritten` files.

What I've deduced from this is that Visual Studio 2010 somehow triggers the Code Contract rewriter properly so the resulting assemblies from the Visual Studio 2010 build is re-used by the command-line MSBuild call, so what my batch script basically does is just copying files to the `build` directory. Rather useless, in other words.

I've read [this](https://stackoverflow.com/questions/1209166/why-is-ccrewrite-exe-not-doing-anything-from-the-command-line), but Jon's problem seems different from mine since `ccrewrite` is obviously doing *something*, but it's just not completing the rewriting for whatever reason. The `Integration.build` file builds the correct configuration (that has Code Contracts enabled in the `.csproj` files) and everything else looks right, it just doesn't work properly.

So, I'm wondering: How do I run MSBuild the way Visual Studio 2010 is where `ccrewrite` does what it's supposed to and doesn't litter my output directory with `.rewritten` and `.pdb.original` files? Does anyone have a perfect example of how an MSBuild file doing proper Code Contracts rewriting looks like?
['https://Stackoverflow.com/questions/3554426', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/61818/']
If you attach a handler to the MouseLeftButtonDown event on the ListView it will only fire when areas outside of a ListViewItem are clicked. Any clicks inside the items will be handled by the items themselves to drive the ListView's selection behavior.

You can make changes to the clickable areas by adjusting the Background ({x:Null} is not clickable, anything else is) and Margin of the ListViewItems by setting an ItemContainerStyle on the ListView. Also make sure that you are not using a null Background on the ListView itself (White is the default, Transparent works too).
I found if I had previously single clicked on an item in the listview (and thereby selecting it), then next double clicked on the empty space in the listview the undesired result of having the previously selected item being actioned as if it had been double clicked on (rather then the empty space). To get around this I used the following code (vb.net):

```
Private Sub ListView1_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs) Handles ListView1.MouseLeftButtonDown

    ListView1.SelectedIndex = -1

End Sub

```

with this code in place double clicking on the empty space de-selects any previously selected items and has the desired effect of nothing appearing to happen for the user when they double click in an empty area.