2011-09-06 6 views
0

나는 현재 목록 상자에서 다음과 같이 배열을 생성하는 HTML을 구문 분석하고- 목록 상자

enter image description here

내가 지금처럼 텍스트 상자에 배열의 각 개체를하고 출력하기입니다

//first line 
flight1.Text = node[0][2]; 
origin1.Text = node[0][3]; 
status1.Text = node[0][7]; 
time1.Text = node[0][6]; 

//second line 

textBlock1.Text = node[1][3]; 
textBlock2.Text = node[1][3]; 
textBlock4.Text = node[1][7]; 
textBlock3.Text = node[1][6]; 

는 결과

enter image description here

에게 있습니다

이미지를 볼 수 있듯이이 작업은 상당히 힘들고 아마도 최선의 방법은 아닙니다.

는 자동으로 모든 비행 시간과 모든 비행 시간 등을 표시 할 수 있도록 .. 같은

뭔가를 배열 예 .. 데이터 템플릿의 목록 상자에 모든 비행 이름의 각 부분을 바인딩 어쨌든 거기 XAML 용

<ListBox Margin="6,6,-12,0" Name="listBox1"> 
       <ListBox.ItemTemplate> 
        <DataTemplate> 
         <StackPanel Margin="0,0,0,17" Width="432" Height="Auto"> 

          <TextBlock Text="{Binding FlightNumber}" Foreground="#FF4BCCF5" FontSize="24" /> 
          <TextBlock Text="{Binding Origin}" TextWrapping="Wrap" FontSize="22" Foreground="#FF969696" /> 
          <TextBlock Text="{Binding Time}" TextWrapping="Wrap" FontSize="20" Foreground="#FF05C16C" /> 
          <TextBlock Text="{Binding Status}" TextWrapping="Wrap" FontSize="20" /> 
         </StackPanel> 
        </DataTemplate> 
       </ListBox.ItemTemplate> 
      </ListBox> 

답변

0

달성하고자하는 것이 확실하지 않습니다. 그러나 일반적으로 나는 다음과 같은 단계를 수행하는 것이 좋습니다 것입니다 : (당신이 당신의 XAML-예에서이 같은 특성을 가진)

  1. 넣어
  2. FlightInformation -Class에서 각 라인을 넣어 HTML을 구문 분석하는 모든 FlightInformationObservableCollection
  3. 에서 -Objects은 ItemsControl
DataTemplate 적용