2011-08-09 5 views
2

私はHeaderName(コンピュータアクセサリのカテゴリ)を持つListPickerを4つ持っています。Listpickerのフィルタリングに関するガイダンス

  1. プロセッサ。
  2. マザーボード。
  3. RAM。
  4. HardDrive。

    Categories.XAML.CS

    public Categories() 
    { 
        InitializeComponent(); 
        this.DataContext = new manufactuers(); 
    } 
    
    private void processorListPicker_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) 
    { 
        processorListPicker.GetBindingExpression(ListPicker.SelectedItemProperty).UpdateSource(); 
    } 
    
    private void motherboardListPicker_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) 
    { 
        motherboardListPicker.GetBindingExpression(ListPicker.SelectedItemProperty).UpdateSource(); 
    } 
    
    private void harddriveListPicker_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) 
    { 
        harddriveListPicker.GetBindingExpression(ListPicker.SelectedItemProperty).UpdateSource(); 
    } 
    
    private void ramListPicker_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) 
    { 
        ramListPicker.GetBindingExpression(ListPicker.SelectedItemProperty).UpdateSource(); 
    } 
    



Categories.XAML

 <!--ContentPanel - place additional content here--> 
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
     <toolkit:ListPicker x:Name="processorListPicker" Header="Processor" 
      ItemsSource="{Binding List1, Mode=TwoWay}" 
      SelectedItem="{Binding SelectedItem1, Mode=TwoWay}" 
      SelectionChanged="processorListPicker_SelectionChanged" Width="360" Margin="54,106,42,0" VerticalAlignment="Top" /> 
     <toolkit:ListPicker x:Name="motherboardListPicker" Header="Motherboard" 
      ItemsSource="{Binding List2, Mode=TwoWay}" 
      SelectedItem="{Binding SelectedItem2, Mode=TwoWay}" 
      SelectionChanged="motherboardListPicker_SelectionChanged" Width="360" Margin="54,191,42,0" VerticalAlignment="Top" /> 
     <toolkit:ListPicker x:Name="harddriveListPicker" Header="HardDrive" 
      ItemsSource="{Binding List3, Mode=TwoWay}" 
      SelectedItem="{Binding SelectedItem3, Mode=TwoWay}" 
      SelectionChanged="harddriveListPicker_SelectionChanged" Width="360" Margin="54,282,42,240" Height="85" /> 
     <toolkit:ListPicker x:Name="ramListPicker" Header="RAM" 
      ItemsSource="{Binding List4, Mode=TwoWay}" 
      SelectedItem="{Binding SelectedItem4, Mode=TwoWay}" 
      SelectionChanged="ramListPicker_SelectionChanged" Width="360" Margin="54,0,42,155" VerticalAlignment="Bottom" Height="85" /> 
    </Grid> 



manufactures.cs - ViewModelに

public class manufacturers 
{ 
    public manufacturers() 
    { 
     // MUST Initialize the selected items 
     SelectedItem1 = "INTEL"; 
     SelectedItem2 = "ASUS"; 
     SelectedItem3 = "WESTERN DIGITAL"; 
     SelectedItem4 = "CORSAIR"; 
    } 

    private IEnumerable<string> manufacturersList 
    { 
     get 
     { 
      return new[] 
       { 
        "INTEL", 
        "AMD", 
        "WESTERN DIGITAL", 
        "CORSAIR", 
        "SEAGATE", 
        "ASUS", 
        "SAMSUNG", 
        "TOSHIBA", 
        "KINGSTON", 
       }; 
     } 
    } 

    public IEnumerable<string> List1 
    { 
     get 
     { 
      return manufacturersList; 
     } 
    } 

    public IEnumerable<string> List2 
    { 
     get 
     { 
      return manufacturersList; 
     } 
    } 

    public IEnumerable<string> List3 
    { 
     get 
     { 
      return manufacturersList; 
     } 
    } 

    public IEnumerable<string> List4 
    { 
     get 
     { 
      return manufacturersList; 
     } 
    } 

    public string SelectedItem1 { get; set; } 
    public string SelectedItem2 { get; set; } 
    public string SelectedItem3 { get; set; } 
    public string SelectedItem4 { get; set; } 
} 

今、ユーザーがクリックしたときどれかこれらのLISTPICKERSのうち、例えば、ユーザ選択プロセッサ - リスピッカ、プロセッサを製造するすべてのベンダは、リセチーカ項目に表示されるべきである。

注:ビューモデルまたはXMLまたはHTMLのオンライン解析から表示できる製造元のリストがあるとします。

+0

http://www.windowsphonegeek.com/articles/listpicker-for -wp7-in-depth –

+0

あなたの質問は何ですか? –

+0

@Derek Beattieに返信してくれてありがとう、私はすでにこのウェブには行きましたが、私のシナリオでは何の助けも得ていません。 –

答えて

1

これは私にとって慣れていないプログラマーなので、私には新しいものなので、コードを与えることはできないので、ビルドの方法を研究しなければならないでしょう。コントロールをビューモデルにバインドさせ、そのビューモデルをINotifyPropertyChangedを使用してUIに送り返します。ボタンをバインドする(私はあなたがボタンをクリックしたので、それをクリックしている)、ビューモデルのコマンドにバインドし、ビューモデルはそのイベントを使用してListBoxに正しいリストを返します。

私はMVVMを実際に教えようとしています。そうしないと、提案することさえできません。

+0

返信のための@hopmedicに感謝しますが、私はあなたの意見を得ていません。 –

0

私は質問を理解していないよ場合を除き:

XAML:ViewModelにで

<Controls:ListPicker Header="Processor:" 
          ItemsSource="{Binding ProcessorMfgs}" 
          Margin="0,499,0,-499" /> 

private List<string> _processorMfgs; 
     public List<string> ProcessorMfgs 
     { 
      get { return _processorMfgs; } 
      set 
      { 
       _processorMfgs = value; 
       NotifyOfPropertyChange(() => ProcessorMfgs); 
      } 
     } 

    ProcessorMfgs = new List<string> 
           { 
            "Intel", "AMD" 
           }; 
関連する問題