2009-11-12 107 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的集合。