Parallels Desktop 4 – disappointing

About a month ago I decided to upgrade my Parallels Desktop 3 to 4. I needed to do a fair amount of Windows Development work and 4 was hailed as providing large increases in performances and this, together with a years subscription to anti-virus, was good enough reason to upgrade. Oh dear, unfortunately disk space is a rare on my laptop so I didn’t backup my v3 disk and just upgraded to 4 feeling sure I would have no need to go back. 4 is so disappointing;
1. Vista performance – everything about using Vista feels sticky and glitchy whereas before it was absolutely fine.
2. Application performance – launching applications feels slow. Everything seems to run as if there is no concurrency. Launch two applications and you may as read a book before you get any sensible response. V3 was great.
3. Switching back to OSX – this was great in V3, a quick ALT-CMD-ENTER and I was out of full-screen Windows and back to OSX in pretty much an instant. In V4 I struggle to even get back to OSX let alone in a speedy fashion.

Overall I’d give V4 2/10 since it does run the applications but it’s pale impression of its older brother. Oh dear, oh dear.

[Edit] – Hopefully I may have found the problem. In the VM configuration is a ‘Show Advanced’ option, selecting this provided access to the CPU options. For some reason it was set to use only one core from my dual CPU. Selecting this seems to have improved things, I’ll update this blog entry should it prove to fix the above problems.

How to use a button within a List Item

One of the problems with Silverlight is that the templating mechanism is really good but you can quickly get a bit stuck. I ran into one such example when I had created a nice DataTemplate for a ListBoxItem that contained a button. When the button is clicked I wanted a specific action to take place in the context of the containing list box item, i.e. I wanted the list box item to be selected because the user has pressed a button within the item.

<DataTemplate x:Key="MyDataTemplate">

     <Grid>

       <Button Content="Edit" Click="Button_Click" />

     </Grid>

</DataTemplate>

 

The problem is that the Button_Click event will fire but none of the event args will explain which of the potentially many buttons has been pressed. WPF uses tricks such as binding the button’s tag to an ancestor element but SL2 doesn’t (I believe) offer this feature. One solution is to skip the button click event and simulate the button via some mouse down events and event bubbling but that seemed too dirty for me. So I thought I could walk the control tree and find which ListBoxItem the button was within. You have to be a bit careful here because templating/themes can introduce a different logical tree so you must walk the tree looking for a ListBoxItem rather than assuming a specific number of hops. BTW, in theory the ListBoxItem itself may have been “styled” out too so you should degrade gracefully if you can’t find the ListBoxItem.

So I wrote some code to loop and walk the FrameworkElement.Parent properties. This didn’t work since the .Parent returned null at the ContentPresenter boundary, i.e. before the ListBoxItem. Still not sure exactly why that is, but I needed a quick solution so I turned to the Visual tree instead. This proved to be the solution…

private void Button_Click(object sender, RoutedEventArgs e)

{

 

    Button buttonSender = sender as Button;

    // which item is containing the button?

    DependencyObject currentElement = buttonSender;

    ListBoxItem selectedItem = currentElement as ListBoxItem;

    DependencyObject theParent = VisualTreeHelper.GetParent(currentElement);

    while (selectedItem == null && theParent != null)

    {               

        currentElement = theParent;

        selectedItem = theParent as ListBoxItem;

        theParent = VisualTreeHelper.GetParent(currentElement);

    }

 

    // if we have found an item then ensure it is selected

    if (selectedItem != null)

    {

        selectedItem.IsSelected = true;

    }

 

}

 

 

Thanks to Keith Mohoney’s Post for the information about the Visual Tree Helper

Silly gotcha when using sample data in Blend

I was working on a list box project and wanted to use Blend to edit my container styles when I was faced with the age old problem of providing Blend with some useful data. So I created a nice little collection class wrapping my target object and asked Blend to use it as a datasource, ensuring that the collection would initialise itself in its constructor. Hurray I had a nice design view with sample data. However, when I switched back to Visual Studio it complained that the resource xaml containing my datasource definition was invalid, the dreaded AEG error. After a great deal of head scratching I realised that somehow Blend had successfully added an x:Name attribute to the resource but my collection class does not derive from any Element and therefore does not have an x:Name. Once I realised that I (ahem) hacked a quick derive-from-user control onto the collection class and we’re up and running again. So watch out, just cause Blend doesn’t complain doesn’t mean it hasn’t generated some dodgy xaml.

Great talk about ADO Data Services

Just finished watching a really could talk from Mix09 about ADO.NET Data Services. I’ve been wondering about where the business rules really fit with ADO.NET DataServices and the Entity Framework. This has gone a long way to helping me understand it, I really recommend it.
 
 
 
 
 

Problems with Win Mobile GPS Sample freezing?

It’s been a while since I last used the GPS Sample for managed code provided in the mobile SDK. So I compiled it and added a reference to it in my project confident I’d have GPS data very soon. I added the gps class to a second form, launched the form and yah I had GPS data. However, when I closed the form the application froze/hung. After examing the code I could see where it was going wrong but I wasn’t sure why. Essentially the sample create a basic message loop by taking out a lock on itself and going into a loop where is uses Wait For Multiple Objects to get the notifications from the GPS driver. One of the notifications it waits for includes "close". However, the code that issus the close notification then takes out another lock. This should be a good idea because it waits for the lock the loop has got to be given up before it continue cleaning up the component. The problem is that the loop never seems to get the close notification so the application is now stuck waiting for a lock it will never get. Now I’m not a 100% what the problem is but it would seem that it’s probably something to do with threads. Therefore I moved the GPS class into the main form and exposed the data to the secondary form. This seems to have done the trick. As I say I don’t understand why this is since the loop certainly recieves the notifications about GPS changes so why not the close? Hopefully I’ll realise what the problem is soon, but in the meantime at least I seem to have a workaround.
 

How to read Car number plates in Google Street Maps

Just had a quick play with Google Street Maps and was interested to see how peoples faces and car number plates are automatically blurred. However, what I also noticed is that the blurring only detects such features in the "current" frame. E.g. you see a car and then move towards it, the car is now at a good resolution and the plate is blurred. However, if you move back a step and then use the zoom button you can easily read the plate. So if your car in visible I would recommend you try this trick and then use the report a problem button to ask for it to be blurred (or removed).

Tip: Virtual PC slow?

I just discovered that when I remote desktop to a machine that is hosting a Virtual PC and try to use the VM from the "player" then the user performance is terrible. You try to move the mouse pointer and it stutters which results in you spending 10mins just to trying to get the mouse-pointer to click a button! Don’t despair there is a workaround. Simply enable remote desktop access to the VM and remote desktop directly to the VM. The UI performance is fine, in fact you wouldn’t know it was a VM.
 

Using IIS in Vista to access your Visual Studio web site project

Developing in Vista certainly presents the odd challenge. Recently I’ve started to develop applications using Live Mesh and I wanted to test out Delegated Authentication which involves running a web site under IIS. Now I’m not used to IIS 7 so after the initial shock of a new UI I setup the required virtual directory and ran my web site. However, I kept getting a rather strange error message;

The requested page cannot be accessed because the related configuration data for the page is invalid.

At first I took that to mean I’d corrupted my web.config file but no that all seemed fine. I eventually tracked down a Test Settings button in IIS. This showed a big warning triangle saying that it couldn’t ensure the site identity would be authorised to access the disk folder. Once I’d set an appropriate user to access the folder everything worked fine.

To access the Test Settings button;

Open IIS->Navigate to your site->Basic Settings (in the right pane)->Test Settings->Click on any line with a warning triangle and read the explanation.

Visual Studio freezing/crashing with Team System Foundation Server

Finally made the switch from Visual Source Safe to Team System Foundation Server today but as luck would have my machine didn’t enjoy the experience. My colleagues machine was running fine, the speed difference in opening a solution or checking in/out was impressive. My machine would just sit there endlessly waiting for the check-in to work until finally I killed it off. It then occurred to me that I hadn’t connected to the Foundation Server in my Team Explorer. Once connected everything seems to be running fine. So my tip is, ensure you’ve connected via Team Explorer before you attempt to use the Source Control.

RIP IE6, goodbye old friend

To start off I’m not an IE6 hater. Much of what is written today vilifies IE6 but for me it’s been a steady, if limited, platform. However, even I concede that it no longer fits the bill. I could second Calling time on IE6 reasons of it’s limited CSS support or it’s now poor JavaScript performance but the final straw for me is the lack of bug fixes. Sure Microsoft will fix the critical (aka security) issues but anything else it just isn’t interested in. E.g. Want to use IIS compression and content-disposition? Yes please, but wait it doesn’t reliably work in IE6 😦 (Edit: note to Systems Admins, you should move away from IE6 too for the same reasons, the users should have the best experience including decent caching, compression, parsing, rendering and bug fixes – all things IE6 doesn’t give you)

So I’m joining throngs of the ivory tower W3Cers and fed up web designers…

Although to balance out the post, Firefox, Safari and Opera can all be royal CSS pains in the….too!