Question

I created listpicker with windows phone toolkit with this code :

<toolkit:ListPicker ExpansionMode="FullScreenOnly" x:Name="myLst" Header="Pilih Peta :" BorderThickness="2" BorderBrush="Black" SelectedIndex="-1" Grid.Row="2">
            <toolkit:ListPicker.FullModeItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding}" Margin="0 24 24 24" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle2Style}" />
                </DataTemplate>
            </toolkit:ListPicker.FullModeItemTemplate>
        </toolkit:ListPicker>

Then i add the data in xaml.cs :

List<string> _tipe = new List<string>();
_tipe.Add("one");
_tipe.Add("two");
_tipe.Add("three");
myLst.ItemsSource = _tipe;

What i want to do is showing MessageBox when selectionChanged in my List Picker. How ?

Thanks Before :)

Was it helpful?

Solution

Attach event handler in XAML :

<toolkit:ListPicker SelectionChanged="ListPicker_SelectionChanged" 
        .......
        >
    .......
</toolkit:ListPicker>

Make the event handler display message box :

private void ListPicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (myLst.SelectedItem != null)
        MessageBox.Show(myLst.SelectedItem.ToString());
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top