2013-01-03 59 views
1

我想在我的MVVM項目中掌握VS2010(不是Blend)的設計數據。Issue with XAML ItemsControl的設計數據

我得到它的頂級VM屬性的工作,但有收藏問題。我使用DevForce進行數據建模,所以最好我的XAML應該是這樣的:

<MaintainTruckViewModel 
    xmlns="clr-namespace:IDATT.Module.Assets.Views" 
    xmlns:data="clr-namespace:IDATT.Model;assembly=IDATT.Model.SL"> 
    <MaintainTruckViewModel.CurrentItem> 
     <data:ASTTruck 
      TruckId="1000" 
      ExternalTruckId="T1000" 
      IsActive="True" 
      VinNumber="1ZAXBV" 
      Make="Volvo" 
      Model="ABC" 
      MakeYear="2010" 
      PlateNumber="ABC 123" 
      PlateIssueAdministrativeArea="MO" 
      Height="110" 
      AxlesCount="3"> 
      <data:ASTTruck.ASTInsurances> 
       <data:ASTInsurance 
        InsuranceKey="1" 
        CompanyName="MainCo" 
        AgentCompanyName="Joes insurance" 
        CoverageAmount = "1000000" 
        DeductibleAmount = "1000" 
        InsuranceType = "General liability" 
        IsActive = "True" 
        PolicyNumber = "123ABC" 
        ExpireOn = "01-01-2012" 
        Note = "This insurance covers all stuff"/> 
      </data:ASTTruck.ASTInsurances> 
     </data:ASTTruck> 
    </MaintainTruckViewModel.CurrentItem> 
</MaintainTruckViewModel> 

我的XAML這個樣子的,我希望看到在設計視圖ASTInsurance數據,但它並沒有顯示出來

<ItemsControl 
        Grid.Row="1" 
        ItemsSource="{Binding CurrentItem.ASTInsurances}"> 

我不知道如何使各種列表從設計數據「工作」。任何指針?我發現的地方,我可以用不同的d:DesignData的列表,並試圖建立這樣的XAML:

<Generic:List 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:Generic="clr-namespace:System.Collections.Generic;assembly=mscorlib" 
    x:TypeArguments="data:ASTInsurance" 
    xmlns:data="clr-namespace:IDATT.Model;assembly=IDATT.Model.SL"> 
       <data:ASTInsurance 
        InsuranceKey="1" 
        CompanyName="Great West" 
        AgentCompanyName="Joes insurance" 
        CoverageAmount = "1000000" 
        DeductibleAmount = "1000" 
        InsuranceType = "General liability" 
        IsActive = "True" 
        PolicyNumber = "123ABC" 
        ExpireOn = "01-01-2012" 
        Note = "This insurance covers all stuff"/> 

</Generic:List> 

現在XAML編輯強調Generic.List並說The type 'Generic:List' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built

回答

3

的問題,試圖在XAML使用System.Collections.Generic.List<T>是(據我所知)XAML的Silverlight方言沒有辦法指定泛型類型參數的值。你得到的錯誤是因爲沒有類型System.Collections.Generic.List沒有類型參數。

一兩件事你可以做的是創造List<T>一個子類,對於類型參數提供一個值,但不包含新,也沒有覆蓋的成員,例如:

public class ASTInsuranceList : List<ASTInsurance> 
{ 
} 

然後,您可以使用ASTInsuranceList對象XAML包含ASTInsurance對象的列表。

+0

賓果!這工作。必須使用收集源並添加單獨的設計數據。 – katit