Search code examples
c#silverlightwindows-phone-7silverlight-toolkit

AutoCompleteBox wrong item selected on SelectedItem (probably xaml issue)


I've been fighting for a while with an autocompletebox in silverlight for windows phone (toolkit) and can't seem to figure out what's happening

I've got a simple search box, binded to a list of custom items. When the selectionchanged event fires, there's somewhere a problem and the item that i click is not the one that comes as SelectedItem. I realized that when i select, let's say the first item, nothing happens. When i select the 2nd item, the 1st one gets actually selected, and so on. It's like if the items were phased out by 1

Here's the important piece code

control :

<toolkit:AutoCompleteBox MinimumPrefixLength="0" Text="{Binding Localizedresources.Search, Source={StaticResource LocalizedStrings}}" Grid.Row="0" VerticalAlignment="Bottom" HorizontalAlignment="Left" MinWidth="270" ItemsSource="{Binding AutoCompleteEntities}" x:Name="txtSelectEntity" ValueMemberBinding="{Binding }" ItemTemplate="{Binding AutoCompleteTemplate}" IsDropDownOpen="True" MaxDropDownHeight="200" >
                    </toolkit:AutoCompleteBox>

template (added a blue border because i thought first that i wasn't touching the right part)

<DataTemplate x:Key="AutoCompleteTemplate">
            <Border BorderBrush="Blue" BorderThickness="2">
                <TextBlock Text="{Binding GermanMeaning}"></TextBlock>
            </Border>
        </DataTemplate>

Solution

  • damn this control ok, it looks like it's related to the same bug that makes this happen

    I had created a transition :

    <toolkit:TransitionService.NavigationInTransition>
            <toolkit:NavigationInTransition>
                <toolkit:NavigationInTransition.Backward>
                    <toolkit:TurnstileTransition
                Mode="BackwardIn" />
                </toolkit:NavigationInTransition.Backward>
                <toolkit:NavigationInTransition.Forward>
                    <toolkit:TurnstileTransition
                Mode="ForwardIn" />
                </toolkit:NavigationInTransition.Forward>
            </toolkit:NavigationInTransition>
        </toolkit:TransitionService.NavigationInTransition>
        <toolkit:TransitionService.NavigationOutTransition>
            <toolkit:NavigationOutTransition>
                <toolkit:NavigationOutTransition.Backward>
                    <toolkit:TurnstileTransition
                Mode="BackwardOut" />
                </toolkit:NavigationOutTransition.Backward>
                <toolkit:NavigationOutTransition.Forward>
                    <toolkit:TurnstileTransition
                Mode="ForwardOut" />
                </toolkit:NavigationOutTransition.Forward>
            </toolkit:NavigationOutTransition>
        </toolkit:TransitionService.NavigationOutTransition>
    

    to make the page switching look cooler, but it appears that those lines of code that have absolutetly nothing to do with the autocompletebox, mess it up. I hope somebody fixes these horrible random bugs at some point, not only they're nasty but they're also super difficult to catch (this made me lose like 3hs)