2009-11-12 96 views
0

我正在將一個asp.net MVC應用程序轉換爲silverlight,並且由於我在mvc應用程序中做了一些「非標準」的事情,所以我很難嘗試工作了解如何在Silverlight MVVM中實現它。ASP MVC to Silverlight MVVM問題

基本上我從元數據中產生了所有的視圖,包括鏈接,按鈕等。我無法理解我的頭如何在Silverlight中執行的一個示例是我將動作集傳遞給了我的視圖,並有一個html幫手類,然後將這些行爲轉換爲鏈接

 public static string GenericLinks(this HtmlHelper htmlHelper, int location, bool inTable, int? parentRecordId, List<ModelAction> 

actions) 
     { 
      int actionNo = 1; 
      StringBuilder text = new StringBuilder(); 
      foreach (var action in actions) 
      { 
       if (action.LocationType == location) 
       { 
        if (inTable) 
         text.Append("<td>"); 
        else 
         if (actionNo > 1) 
          text.Append(" | "); 
        text.Append(htmlHelper.ActionLink(action.Label, action.ActionTypeLookup.CodeName, new { actionId = action.ModelActionId, 

parentRecordId = parentRecordId })); 
        if (inTable) 
         text.Append("</td>"); 
        actionNo++; 
       } 
      } 
      return text.ToString(); 
     } 

這真的在MVC中運行良好。

MVVM中的equivent會是什麼? 我希望我可以做更多的事情,更多的沿着我的viewmodel創建我的行動,並以某種方式綁定到我認爲這些行動......

回答

0

對於這樣的事情,你可能需要創建一個自定義控件。然後你可以把它放在你的視圖中,並將它綁定到ViewModel中存在的Actions的集合。