2017-10-30 7 views
0

syncfusion 격자 컨트롤을 사용하고 있지만이 질문은 일반적인 것으로 가정합니다.격자에서 드롭 다운 열에 바인딩 할 수있는 컬렉션 모델 속성

나는이 표를 고객 목록에 바인딩했습니다. 이 속성 (이름, 전자 메일, 연락처 번호 등)은 그리드 내부에 확인을 표시합니다.

이제 클라이언트가 하나 이상의 주소를 가질 수 있음을 예상합니다 (특히 비즈니스 지사 인 경우).

그래서, 잠재적 인 1+ 주소를 표시하는 표가있는 드롭 다운 열 유형도 있습니다.

문제가 여기에 아무 것도 표시되지 않습니다.

그래서 ..

내 XAML은 다음과 같습니다

<syncfusion:SfDataGrid 
      ItemsSource="{Binding Path=HeartBeat.ConciseCustomer}"> 
     <syncfusion:SfDataGrid.Columns> 
      <syncfusion:GridTextColumn MappingName="Customer.FirstName" HeaderText="First Name" Width="150" /> 
      <syncfusion:GridTextColumn MappingName="Customer.LastName" HeaderText="Last Name" Width="150" /> 
      <syncfusion:GridComboBoxColumn MappingName="Address1" DisplayMemberPath="Address1" ItemsSource="{Binding Addresses}" /> 
      <syncfusion:GridTextColumn MappingName="Customer.ContactNo1" HeaderText="Contact No" Width="130" /> 
      <syncfusion:GridTextColumn MappingName="Customer.EmailAddress1" HeaderText="Email Address" Width="300"/> 
     </syncfusion:SfDataGrid.Columns> 
    </syncfusion:SfDataGrid> 

내 VM은 ...

private ObservableCollection<ConciseCustomer> _conciseCustomer; 

public ObservableCollection<ConciseCustomer> ConciseCustomer 
{ 
    get => _conciseCustomer; 
    set 
    { 
     _conciseCustomer = value; 
     RaisePropertyChanged("ConciseCustomer"); 
    } 
} 

내 모델

은 다음과 같습니다

public class Address 
{ 
    public Int64 AddressId { get; set; } 
    public string AddressRef { get; set; } 
    public string Address1 { get; set; } 
    public string Address2 { get; set; } 
    public string Address3 { get; set; } 
    public string Town { get; set; } 
    public string PostCode { get; set; } 
    public string County { get; set; } 
    public string Country { get; set; } 
    public string CustomerRef { get; set; } 
    public bool Active { get; set; } 
    public string AccountRef { get; set; } 
    public DateTime? ServerTs { get; set; } 
    public string ServerRef { get; set; } 
} 

public class Customer 
{ 
    public Int64 CustomerId { get; set; } 
    public string CustomerRef { get; set; } 
    public string CustomerFriendlyRef { get; set; } 
    public string Title { get; set; } 
    public string FirstName { get; set; } 
    public string MiddleName { get; set; } 
    public string LastName { get; set; } 
    public string ContactNo1 { get; set; } 
    public string ContactNo2 { get; set; } 
    public string ContactNo3 { get; set; } 
    public string EmailAddress1 { get; set; } 
    public string EmailAddress2 { get; set; } 
    public DateTime Doe { get; set; } 
    public bool Active { get; set; } 
    public string AccountRef { get; set; } 
    public DateTime? ServerTs { get; set; } 
    public string ServerRef { get; set; } 
} 

VM :

public class ConciseCustomer : VMS 
{ 
    private Customer _customer; 
    private ObservableCollection< Address> _addresses; 

    public Customer Customer 
    { 
     get => _customer; 
     set 
     { 
      _customer = value; 
      RaisePropertyChanged("Customer"); 
     } 
    } 

    public ObservableCollection<Address> Addresses 
    { 
     get => _addresses; 
     set 
     { 
      _addresses = value; 
      RaisePropertyChanged("Addresses"); 
     } 
    } 

} 

public class ApplicationViewModel : VMS 
{ 
    public ApplicationViewModel() 
    { 
     HeartBeat = new HeartBeat 
     { 
      BookingWizard = new BookingWizard(), 
      LookUps = new LookUps() 
     }; 
    } 
    private HeartBeat _heartBeat; 

    public HeartBeat HeartBeat 
    { 
     get => _heartBeat; 
     set 
     { 
      _heartBeat = value; 
      RaisePropertyChanged("HeartBeat"); 
     } 
    } 
} 

출력 창의 오류는?

System.Windows.Data 오류 : 40 : BindingExpression 경로 오류 : 'Addresses'속성이 'object'에 없습니다. 'ApplicationViewModel'(HashCode = 59362130) '. BindingExpression : 경로 = 주소; DataItem = 'ApplicationViewModel'(HashCode = 59362130); 대상 요소는 'GridComboBoxColumn'(HashCode = 54875957)입니다. 대상 속성은 'ItemsSource'(유형 'IEnumerable')

나는이 오류를 이해하고 있지만 '수정'할 수는 없습니다. '하위'항목 소스를 상위 항목 소스와 '관련'되게하려면 어떻게해야합니까?

<syncfusion:GridTemplateColumn MappingName="Address1" 
           syncfusion:FocusManagerHelper.WantsKeyInput="True"> 
    <syncfusion:GridTemplateColumn.CellTemplate> 
     <DataTemplate> 
      <TextBlock Text="{Binding Address1}" /> 
     </DataTemplate> 
    </syncfusion:GridTemplateColumn.CellTemplate> 
    <syncfusion:GridTemplateColumn.EditTemplate> 
     <DataTemplate> 
      <ComboBox SelectedItem="{Binding Address1}" 
         ItemsSource="{Binding Addresses}" 
         DisplayMemberPath="Address1" /> 
     </DataTemplate> 
    </syncfusion:GridTemplateColumn.EditTemplate> 
</syncfusion:GridTemplateColumn> 

을하지만 당신가 AddressCustomer A를 연결하는 가정하는 방법을 아직 데이터 모델에서 명확하지 않다 :

+0

Thiis [WPF 오류 40 BindingExpression 경로 오류 : 'object'에 속성이 없음] (https://stackoverflow.com/questions/16173869/wpf-error-40-bindingexpression-path-error-property-not-found -on-object)가 도움이 될 수 있습니다. – mmushtaq

+0

@ mmushtaq 감사합니다. 이미 보았지만이 시나리오에서는 도움이되지 않습니다. –

답변

0

당신은 GridComboBoxColumnGridTemplateColumn로 교체 시도 할 수 있습니다.

+0

답변 해 주셔서 감사합니다. 나는 오늘 아침에 이것을 빨리 시험해 보았지만 효과가 없었다. 나는 내 대답을 늘릴 것이다. –