Question

I'm having a hard time with the ListPicker from the Windows Phone Toolkit.

The ListPicker is declared like this on a Register Page:

<toolkit:ListPicker ExpansionMode="ExpansionAllowed" 
                                        FullModeHeader="Countries" 
                                        Template="{StaticResource ListPickerControlTemplate}"
                                        FullModeItemTemplate="{StaticResource ListPickerFullItemTemplate}"
                                        ItemsSource="{Binding CountryList}"
                                        SelectedItem="{Binding SelectedCountry}" />

Everything works fine, except that if I go into the full mode of the listpicker and pick an item, every other TextBox (e.g. for the Email, Password etc.) on the page now has an empty content, not even watermark hints are displayed anymore. I'm using PhoneTextBoxes from the Toolkit:

                <StackPanel>
                    <!-- name -->
                    <toolkit:PhoneTextBox Hint="firstname" Style="{StaticResource TransparentToolkitTextBoxStyle}" Text="{Binding FirstName}"/>
                    <toolkit:PhoneTextBox Hint="lastname" Style="{StaticResource TransparentToolkitTextBoxStyle}" Text="{Binding LastName}"/>
                    <!-- email -->
                    <toolkit:PhoneTextBox Hint="email" Style="{StaticResource TransparentToolkitTextBoxStyle}" Text="{Binding Email}"/>
                </StackPanel>

All these have Bindings to a ViewModel. Any idea why the text is lost?

Sometime in the full mode the ListPicker also freezes and I have to press the back key and try again...

Was it helpful?

Solution

You are not binding the ListPicker ItemTemplate. Bind it like this

<toolkit:ListPicker.ItemTemplate>
    <DataTemplate>
        <StackPanel Orientation="Horizontal">
            <toolkit:PhoneTextBox Hint="firstname" Style="{StaticResource TransparentToolkitTextBoxStyle}" Text="{Binding FirstName}"/>
        </StackPanel>
    </DataTemplate>
</toolkit:ListPicker.ItemTemplate>

Make sure you are not setting any text box in OnNavigatedTo method. if so your TextBox will reset again. So, Do not Set any TextBox in that Method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top