title: set selecteditem to listpicker
body: <h2>XAML</h2>
  
  <pre class="lang-xml prettyprint-override"><code> &lt;DataTemplate x:Name="PickTmplItemTipo"&gt;
              &lt;StackPanel Orientation="Horizontal"&gt;               
                  &lt;TextBlock Text="{Binding tipo}" /&gt;                
              &lt;/StackPanel&gt;
          &lt;/DataTemplate&gt;
  
          &lt;DataTemplate x:Name="PickTmplFullTipo"&gt;            
              &lt;StackPanel Orientation="Horizontal" Margin="0,25,0,0"&gt;
                  &lt;TextBlock Name="lblTipo" Width="350" Text="{Binding tipo}" FontFamily="{StaticResource PhoneFontFamilyLight}" TextWrapping="Wrap" FontSize="{StaticResource PhoneFontSizeExtraLarge}" /&gt;
              &lt;/StackPanel&gt;
          &lt;/DataTemplate&gt;
  
  
  &lt;toolkit:ListPicker    
           Grid.Row="0"
           ItemsSource="{Binding}" Margin="21,0,22,0" 
           Header="{Binding Source={StaticResource LocalizedStrings}, Path=Localizedresources.strTipoUni}" 
           FullModeHeader="{Binding Source={StaticResource LocalizedStrings}, Path=Localizedresources.strTipoUni}" 
           FullModeItemTemplate="{Binding Source={StaticResource PickTmplFullTipo}}" 
           ItemTemplate="{Binding Source={StaticResource PickTmplItemTipo}}" 
           Name="lPickTipo" 
           TabIndex="0" 
           Height="98" 
           VerticalAlignment="Top" 
           ExpansionMode="FullScreenOnly" 
           Tap="lPickTipo_Tap" 
           SelectionChanged="lPickTipo_SelectionChanged" /&gt;
  </code></pre>
  
  <h2>C#</h2>
  
  <p><strong>Fill listpicker:</strong></p>
  
  <pre class="lang-cs prettyprint-override"><code>    List&lt;tipos&gt; _lstTipos { get; set; }
      private void cargaLista()
      {
          using (serviciosDBDataContext miDataContext = new serviciosDBDataContext(conn))
          {
              _lstTipos = miDataContext.tipos.ToList();
          }
  
          this.lPickTipo.ItemsSource = _lstTipos;
      }
  </code></pre>
  
  <p><strong>Set selecteditem:</strong></p>
  
  <p>if I try this, returns this error "<strong>SelectedItem must always be set to a valid value</strong>."</p>
  
  <pre><code>this.lPickTipo.SelectedItem = myStringValue;
  </code></pre>
  
  <p>And if I try the next thing, returns null error:</p>
  
  <pre><code>this.lPickTipo.SelectedItem = lPickTipo.Items.First(x =&gt; (x as ListPickerItem).Content.ToString() == myStringValue);
  </code></pre>
  
  <p>But I can not to set by selectindex because I dont know which index equival</p>