【问题标题】:listPicker WP 8 selectionChange?listPicker WP 8 selectionChange?
【发布时间】:2014-05-04 11:22:36
【问题描述】:

我用windows phone toolkit 用这段代码创建了listpicker:

<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>

然后我在 xaml.cs 中添加数据:

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

我想要做的是在我的列表选择器中的 selectionChanged 时显示 MessageBox。怎么样?

感谢之前:)

【问题讨论】:

    标签: c# windows-phone-8 listpicker windows-phone-toolkit


    【解决方案1】:

    在 XAML 中附加事件处理程序:

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

    使事件处理程序显示消息框:

    private void ListPicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (myLst.SelectedItem != null)
            MessageBox.Show(myLst.SelectedItem.ToString());
    }
    

    【讨论】:

    • 就是这样 :D 非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多