Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //XAML code
- <toolkit:ListPicker x:Name="listPickerCountryLogin" Grid.Row="0" ExpansionMode="ExpansionAllowed" SelectionChanged="listPickerCountryLogin_SelectionChanged" HorizontalAlignment="Left" Margin="14,43,0,0" VerticalAlignment="Top" Width="436" FullModeHeader="Select Country" Background="White" BorderBrush="White">
- <toolkit:ListPicker.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{Binding Country}" Width="250" />
- </StackPanel>
- </DataTemplate>
- </toolkit:ListPicker.ItemTemplate>
- <toolkit:ListPicker.FullModeItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{Binding Country}" Width="300" Margin="0,0,0,20" FontSize="24"/>
- </StackPanel>
- </DataTemplate>
- </toolkit:ListPicker.FullModeItemTemplate>
- </toolkit:ListPicker>
- <toolkit:ListPicker x:Name="listPickerCCLogin" Grid.Row="1" ExpansionMode="FullScreenOnly" SelectionChanged="listPickerCCLogin_SelectionChanged" Width="80" HorizontalAlignment="Left" Margin="14,10,0,0" VerticalAlignment="Top" FullModeHeader="Select Country" Background="White" BorderBrush="White">
- <toolkit:ListPicker.ItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal">
- <TextBlock Name="lblCC" Text="{Binding CC}" Width="235" />
- </StackPanel>
- </DataTemplate>
- </toolkit:ListPicker.ItemTemplate>
- <toolkit:ListPicker.FullModeItemTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{Binding Country}" Width="300" Margin="0,0,0,20" FontSize="24"/>
- </StackPanel>
- </DataTemplate>
- </toolkit:ListPicker.FullModeItemTemplate>
- </toolkit:ListPicker>
- <Button Content="change" Grid.Row="2" Height="200" Click="Button_Click" BorderThickness="1" />
- //C# code
- public MainPage()
- {
- InitializeComponent();
- List<Countries> source = new List<Countries>();
- source.Add(new Cities() { Country = "ES", CC = "10" });
- source.Add(new Cities() { Country = "US", CC = "20" });
- source.Add(new Cities() { Country = "UK", CC = "30" });
- source.Add(new Cities() { Country = "MX", CC = "40" });
- this.listPickerCountryLogin.ItemsSource = source;
- this.listPickerCCLogin.ItemsSource = source;
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- WebClient client = new WebClient();
- client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
- client.DownloadStringAsync(new Uri("http://api.twitter.com/1/statuses/public_timeline.json", UriKind.Absolute));
- }
- void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
- {
- //var deserialized = JsonConvert.DeserializeObject(e.Result);
- Dispatcher.BeginInvoke(new System.Action(delegate()
- {
- listPickerCountryLogin.SelectedIndex = 1;
- listPickerCCLogin.SelectedIndex = 1;
- }));
- }
- private void listPickerCountryLogin_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (listPickerCountryLogin.SelectedIndex >= 0 && listPickerCountryLogin.SelectedIndex < listPickerCCLogin.Items.Count)
- listPickerCCLogin.SelectedIndex = listPickerCountryLogin.SelectedIndex;
- }
- private void listPickerCCLogin_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (listPickerCCLogin.SelectedIndex >= 0 && listPickerCCLogin.SelectedIndex < listPickerCountryLogin.Items.Count)
- listPickerCountryLogin.SelectedIndex = listPickerCCLogin.SelectedIndex;
- }
- //And finally Countries class is:
- public class Countries
- {
- public string Country
- {
- get;
- set;
- }
- public string CC
- {
- get;
- set;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement