views:

436

answers:

3

The following bit of code works on Vista as expected (focus is moved down the ListView), but on XP SP3 (with .Net 3.5 SP1 on both) it moves only between the first two items of the ListView.

if (myListView.SelectedItem != null) {
    IInputElement orig = FocusManager.GetFocusedElement(this);
    FocusManager.SetFocusedElement(this, myListView);
    ListViewItem lvi = myListView.ItemContainerGenerator.ContainerFromItem(myListView.SelectedItem) as ListViewItem;
    TraversalRequest down = new TraversalRequest(FocusNavigationDirection.Down);

    Boolean result = lvi.MoveFocus(down);
    Console.WriteLine(result.ToString());
    FocusManager.SetFocusedElement(this, orig);
}

I'm calling this code from the window's previewkeydown event, when the focus is in a textbox. I'm digging into the framework now to try and find what is different between XP and Vista inside of MoveFocus(). I feel like I'm doing web development again, testing browsers for quirks...

A: 

My feeling in general is that many features in WPF uses technology that is new in Vista, and not supported in XP. Things I have experienced are mainly related to visual effects, but in your case, it is obviously something else.

My initial thought in your case is that there are some windows messages that are new in Vista that does not work in XP.

awe
+1  A: 

Did you run Windows XP Service Pack2, in the doc the requirements are : Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

Msdn doc

For me, I develop WPF apps under XP and all is working right...

Coolweb
A: 

The requirements for VS2008 are met by XP SP2, WPF is best suited for Windows Vista/Windows 7, that might be the case.

Raghav Bali