2012-10-10 4 views
0

MyCustomers를 TreeListControl에 바인딩하려합니다. TreeListColumn FieldName = "Id"Binding = "CustomerId를 바인딩하는 방법" 어떻게 할 수 있습니까?DevExpression에서 ViewModel을 바인딩하는 방법 TreeListColumn?

<dxg:TreeListControl Name="MyControl" ItemsSource="{Binding Path=MyCustomers}" 
    Height="296" Width="750" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left"> 
    <dxg:TreeListControl.Columns> 
     <dxg:TreeListColumn FieldName="Id" Binding="How to Bind CustomerID ?????" /> 
     <dxg:TreeListColumn FieldName="CustomerGroup" Binding="How to Bind CustomerGroup ?????" /> 
    </dxg:TreeListControl.Columns> 
    <dxg:TreeListControl.View> 
     <dxg:TreeListView AutoWidth="True" KeyFieldName="Id" ParentFieldName="ParentId" NavigationStyle="Row" /> 
    </dxg:TreeListControl.View> 
</dxg:TreeListControl> 

뷰 모델 :

public class CustomerViewModel : BaseViewModel 
{ 
    public IList<Model.App.Customer> MyCustomers 
    { 
     get; 
     private set; 
    } 

    public CustomerViewModel() 
    { 
     CustomerDetail = new CustomerDetail(); 
     this.MyCustomers = CustomerRespiratory.SelectMyCustomers(); 
    } 
} 

모델 : 당신은 부모 필드로 키 필드와 CustomerGroup로 CustomerID를 지정해야합니다

public class Customer 
{ 
    public int CustomerID { get; set;} 
    public int CustomerGroup { get; set;} 
} 
+2

당신이 시도 무엇 첫눈에 내가 바인딩 말할 = "{CustomerID를 바인딩}"당신이 필요로 될 수있다 – michele

답변

1

. 아주 명확하게 "Binding to Self-Referential Data Structure" 문서에서 설명 :

<dxg:TreeListControl ItemsSource="{Binding Path=MyCustomers}"> 
    <dxg:TreeListControl.Columns> 
     <dxg:TreeListColumn FieldName="CustomerId"/> 
     <dxg:TreeListColumn FieldName="CustomerGroup"/> 
    </dxg:TreeListControl.Columns> 
    <dxg:TreeListControl.View> 
     <dxg:TreeListView KeyFieldName="CustomerId" ParentFieldName="CustomerGroup" 
       AutoWidth="True" NavigationStyle="Row" /> 
    </dxg:TreeListControl.View> 
</dxg:TreeListControl> 

당신은 "TreeListView Data Binding" 문서의 자세한 내용을보실 수 있습니다.

도 참조 :
DXTreeList Getting Started - Lesson 1 - Binding to Data

관련 문제