1

wp7 アプリに listpicker コントロールがあります。そして、必要に応じて選択したインデックスを設定したい。リストピッカーに100個のアイテムがあるとしましょう。選択したインデックスを40未満に設定するとうまくいきます。しかし、選択したインデックスを 50 以上に設定すると、空白になり、UI は更新されませんが、バックエンドでは正しいアイテムが表示されます。

サンプルプロジェクト : http://yaariyan.net/Test_Project.rar

このプロジェクトでは、あなたが得ることができます

  1. すべてのソース

  2. テストするXAPファイルも

  3. 再現する手順

  4. エラーのスナップショット

最後の 2 つのボタンで再生するだけで、問題を簡単に再現できます。

Windows Phone 7.1.1 SDK と Silverlight Take Kit 2011 年 11 月バージョンを使用しています。

DLLも私のプロジェクトで参照している私のフォルダにあります

4

2 に答える 2

0

私は同じ問題を経験しました。残念ながらまだ解決策は思いつきませんが、問題を少し絞り込みました。SelectedIndex問題が40 ~ 50 (私の場合は 48) のどこかで発生しているように見えることを確認できます。

絞り込むために私が行ったのは、新しい WP ソリューションを作成し、ビューに2 つのListPickerコントロールとボタンを追加することだけでした。MainPage.xamlコードを使用して両方のリストに 50 個の文字列を追加SelectedIndexし、最初のリストでは 0 に、2 番目のリストでは 50 に設定します。

このボタンは、次のように SelectedIndex プロパティの単純な切り替えを行います。

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        int tempindex = listPicker1.SelectedIndex;
        listPicker1.SelectedIndex = listPicker2.SelectedIndex;
        listPicker2.SelectedIndex = tempindex;
    }

私はプロジェクトを実行し、最終的にこれになりました(映画がすべてを語っていると思います):

http://screencast.com/t/T6mZ7FEdUF

于 2012-08-17T18:39:06.510 に答える
0

私はあなたの問題を解決しました。私がしたことは、ListPicker Itemsource をコード ビハインドではなく .xaml にバインドしたところ、完全に機能しました。

これは、提供されたファイルで編集された .xaml コードです。

        <toolkit:ListPicker ItemsSource="{Binding LstCountry}" SelectedIndex="55" x:Name="listPickerCountrySignup" Height="72" HorizontalAlignment="Left" Margin="14,43,0,0" VerticalAlignment="Top" Width="436" FullModeHeader="Select Country" Background="White" BorderBrush="White" CacheMode="BitmapCache" >

.xaml.cs コード

public partial class MainPage : PhoneApplicationPage, INotifyPropertyChanged { // コンストラクタ public MainPage() { InitializeComponent(); BindList(); this.DataContext=これ; }

    public class country 
    {
        public int CountryID { get; set; }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    void NotifyPropertyChanged(String propertyName)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (null != handler)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    List<country> _lstCountry;
    public List<country> LstCountry
    {
        get{return _lstCountry;}
        set{
            if(_lstCountry!=value)
            {
                _lstCountry = value;
                NotifyPropertyChanged("LstCountry");
            }
        }
    }
    void BindList()
    {
        LstCountry = new List<country>();

        for (int i = 0; i <= 100; i++)
        {
            LstCountry.Add(new country { CountryID = i });
        }
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        listPickerCountrySignup.SelectedIndex = 15;
    }

    private void button2_Click(object sender, RoutedEventArgs e)
    {
        listPickerCountrySignup.SelectedIndex = 25;
    }

    private void button3_Click(object sender, RoutedEventArgs e)
    {
        listPickerCountrySignup.SelectedIndex = 39;
    }

    private void button4_Click(object sender, RoutedEventArgs e)
    {
        listPickerCountrySignup.SelectedIndex = 55;
    }

    private void button5_Click(object sender, RoutedEventArgs e)
    {
        listPickerCountrySignup.SelectedIndex = 75;
    }
}
于 2012-08-21T02:56:18.103 に答える