windows-phone-8listpicker

Wp8 listpicker-display data in a text block


I am implementing listpicker in my application;but unable to display the list picker value in the textblock.how can i accomplish it?.


Solution

  • You can use data binding for this. Its much easier.

    <toolkit:ListPicker Name="lstPicker">
        <sys:String>Option 1</sys:String>
        <sys:String>Option 2</sys:String>
        <sys:String>Option 3</sys:String>
        <sys:String>Option 4</sys:String>
    </toolkit:ListPicker>
    
    <TextBlock Name="txtBox" 
               Text="{Binding ElementName=lstPicker, Path=SelectedItem}"
               Style="{StaticResource PhoneTextLargeStyle}" 
               VerticalAlignment="Bottom" />
    

    You set the SelectedItem of the ListPicker as the Value of the TextBox