Label's Target doesn't work properly for ListBox

Put the following XAML code into XAMLPad:

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>

<StackPanel Orientation="Vertical">

<Label Content="_ListBox:" Target="{Binding ElementName=lb}" HorizontalAlignment="Center"/>

<ListBox Name="lb" Width="200" Height="80">
<ListBoxItem>Line 1</ListBoxItem>
<ListBoxItem>Line 2</ListBoxItem>
<ListBoxItem>Line 3</ListBoxItem>
<ListBoxItem>Line 4</ListBoxItem>
<ListBoxItem>Line 5</ListBoxItem>
</ListBox>

<Button Content="Focus Stealer" HorizontalAlignment="Center" Margin="10"/>
</StackPanel>
</Page>

1. Select "Line 3" in the ListBox.
2. Click on the "Focus Stealer" button.
3. Hit Alt+L to go to the ListBox.

Notice the ListBox itself now has focus. Down arrow (on the keyboard) will move the selected item back to "Line 1".

This seems wrong. Or am I just misunderstanding how the Target property of a Label works



Answer this question

Label's Target doesn't work properly for ListBox

  • Maulik Soni

    Thanks -- I figured it was a bug, but I wanted to make sure I wasn't being stupid. I'll leave this open a bit longer to see if there are any other comments.
  • GP.Software

    Hmmm... you'd expect it to go to "Line 4", right I'd have to agree this sounds like a bug. You should post a bug to the product feedback site.

    Just my 2¢,
    Drew


  • Label's Target doesn't work properly for ListBox