2010-01-19 2 views
2

WPF 컨트롤을 SQL Server 속성에 바인딩하려면 어떻게해야합니까? Like List a Listbox리포지토리 패턴을 통해 SQL 서버에 WPF 컨트롤을 바인딩

<ListView> 
     <ListView.View> 
      <GridView> 
       <GridViewColumn Header="Name"> 
       <GridViewColumn Header="Date Assigned"> 
       <GridViewColumn Header="Date Due"> 
      </GridView> 
     </ListView.View> 
     <!-- iterate through all the Names in the database and output under GridViewColumn Name --> 
     <!-- iterate through all the DateAssigned in the database and output under GridViewColumn Date Assigned --> 
     <!-- iterate through all the DateDue in the database and output under GridViewColumn Date Due --> 
    </ListView> 

저는 엔터티 프레임 워크와 저장소 패턴을 사용하고 있습니다. 그래서 모든 이름을 _repository.ToList();

답변

2

이 시도 : listViewName.ItemsSource = _repository.ToList();

나는이처럼 XAML을 단순화 것 : {Binding 후 텍스트 당신이에서 반환 컬렉션에있는 항목의 속성의 이름이

<ListBox x:Name="listViewName"> 
    <ListBox.Resources> 
     <DataTemplate> 
      <Grid Height="22" Width="Auto"> 
       <TextBlock Text="{Binding Name}" /> 
       <TextBlock Text="{Binding DateAssigned}" /> 
       <TextBlock Text="{Binding DateDue}" /> 
      </Grid> 
     </DataTemplate> 
    </ListBox.Resources> 
</ListBox> 

인 경우 _저장소.

관련 문제