2012-05-01 7 views
0

私はテキストボックスでコントロールを持っています。ユーザーが数行のテキストを入力してボタンで送信した後、テキストのすべての行について、ユーザーが何らかの値を選択しなければならないグリッドを持つ子ウィンドウを表示する必要があります。SilverlightでChildWindowsを使用するループ?

ユーザーが5行のテキストをクライアント名(1行1つのクライアント名)で入力したとします。

それぞれが[送信]をクリックすると、ChildWindowからSalespersonを選択する必要があります。

もちろん、私のループの効果は、同時に5つのChildWindowsを開くことです。

Childwindowグリッドから要素を選択した後で初めて、次のChildWindowを取得できますか?

答えて

1

あなたのコントロールには、このようなクラスが使用されることがあります。

あなたのコントロールが既にあなたがこれを行うことができ、「名前」と呼ばれるリストにテキストボックスから名前を分割していると仮定すると、
public class SalesPersonSelector 
{ 
    private Queue<string> _clientNamesToProcess; 
    private Dictionary<string, SalesPerson> _selectedSalesPersons; 
    private Action<IDictionary<string, SalesPerson>> _onComplete; 
    private string _currentClientName; 

    public void ProcessNames(IEnumerable<string> clientNames, Action<IDictionary<string, SalesPerson>> onComplete) 
    { 
     this._clientNamesToProcess = new Queue<string>(clientNames); 
     this._selectedSalesPersons = new Dictionary<string, SalesPerson>(); 
     this._onComplete = onComplete; 
     this.SelectSalespersonForNextClient(); 
    } 

    private void SelectSalespersonForNextClient() 
    { 
     if (this._clientNamesToProcess.Any()) 
     { 
      this._currentClientName = this._clientNamesToProcess.Dequeue(); 
      ChildWindow childWindow = this.CreateChildWindow(this._currentClientName); 
      childWindow.Closed += new EventHandler(childWindow_Closed); 
      childWindow.Show(); 
     } 
     else 
     { 
      this._onComplete(this._selectedSalesPersons); 
     } 
    } 

    private ChildWindow CreateChildWindow(string nextClientName) 
    { 
     // TODO: Create child window and give it access to the client name somehow. 
     throw new NotImplementedException(); 
    } 

    private void childWindow_Closed(object sender, EventArgs e) 
    { 
     var salesPerson = this.GetSelectedSalesPersonFrom(sender as ChildWindow); 
     this._selectedSalesPersons.Add(this._currentClientName, salesPerson); 
     this.SelectSalespersonForNextClient(); 
    } 

    private SalesPerson GetSelectedSalesPersonFrom(ChildWindow childWindow) 
    { 
     // TODO: Get the selected salesperson somehow. 
     throw new NotImplementedException(); 
    } 
} 

var salesPersonSelector = new SalesPersonSelector(); 
salesPersonSelector.ProcessNames(names, selections => 
    { 
     foreach (var selection in selections) 
     { 
      var clientName = selection.Key; 
      var salesPerson = selection.Value; 
      // TODO: Do something with this information. 
     } 
    }); 

私はこれが、Visual Studioのをテストしていません私に赤い波線を与えていません。

+0

私はそれが好きです。ありがとう:) – user278618

関連する問題