2012-03-09 5 views
0

WinPhone 7 프로그래밍에서 비디오 제목과 축소판을 보여주는 목록 상자가 있습니다. listbox를 ItemsSource에 연결했습니다. XAML에서WinPhone7 프로그래밍 ListBox 다중 열

listbox1.ItemsSource = videos; 

:

<Listbox.ItemTemplate> 
    <DataTemplate> 
    <StackPanel> 
     <TextBlock Text="{Binding title}"/> 
     <Image Source="{Binding thumbnail}"/> 
    </StackPanel> 
    </DataTemplate> 
</Listbox.ItemTemplate> 

이제 내 목록 상자는 각 행의 제목 텍스트 및 썸네일 이미지가 하나의 열이 있습니다. 하지만 2 열의 목록 상자는 각 열에 제목 텍스트와 각 행의 축소판 이미지가 있습니다.

나는 해결책을 찾기 위해 노력하고 많은 시간을 보냈어요,하지만 난 그것을 찾을 수 없습니다

--------------------------- 
| title1  | title2 | 
| thumb1  | thumb2 | 
---------------------------- 
| title3  | title4 | 
| thumb3  | thumb4 | 
...

목록 상자. Stack overflow guys가이 문제를 해결할 수 있기를 바랍니다. 모든 아이디어는 환영합니다. 내가 뭔가를 누락하지 않는 한 감사

답변

1

, 당신이 찾고있는 무엇인가요 그냥 수평

<StackPanel Orientation="Horizontal"/> 

StackPanel의 방향을 설정할 수 있습니다 날 것으로 보인다? 그렇지 않으면 정교하게하십시오.

편집 : WrapPanel을 ItemsPanel로 사용.

이 예제에서는 Silverlight for Windows Phone ToolkitWrapPanel을 사용합니다. 이 파일을 다운로드하여 설치하거나 작업 할 항목에 대한 네임 스페이스 정의를 포함해야 할 수도 있습니다!

또한 WrapPanel은 행당 맞을만큼 많은 항목을 줄 것입니다. 따라서 정확하게 두 개의 항목 만 연속으로 사용하려면 ListBox의 너비를 조정해야 할 수 있습니다.

<PhoneApplicationPage 
    .... 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" 
.... 
> 

<!-- More Stuff --> 

<ListBox> 
    <ListBox.ItemsPanel> 
     <ItemsPanelTemplate> 
      <toolkit:WrapPanel/> 
     </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 
    <Listbox.ItemTemplate> 
      <!-- your template --> 
    </Listbox.ItemTemplate> 
</ListBox> 

<!-- More Stuff --> 
+0

덕분에, 윌렘는 목록 상자는 내 질문의 형식이다 잃게됩니다. – ttotto

+0

내 listbox에는 2 개의 열과 여러 개의 행이 있습니다. 각 셀에는 제목과 엄지 손가락이 있어야하며 연속적이어야합니다. – ttotto

+0

@ttotto : 지금 무엇이 잘못 되었는가, 그리고 어떻게 보이게 될지 더 잘 보여줄 수 있습니까? –

4

사용

 <ListBox.ItemsPanel> 
      <ItemsPanelTemplate> 
       <toolkit:WrapPanel Orientation="Horizontal"/> 
      </ItemsPanelTemplate> 
     </ListBox.ItemsPanel> 
     <ListBox.ItemTemplate> 
      <DataTemplate> 
       <StackPanel Orientation = "Horizontal"> 
       <TextBlock Text="{Binding title}"/> 
       <Image Source="{Binding Thumbnail}"/> 
       <StackPanel/> 
      </DataTemplate> 
     </ListBox.ItemTemplate> 
+0

감사 핵,하지만 내 목록 상자 2columns 및 여러 행이 있습니다. (행 1, col1) title1, thumb1 (행 1, col2) title2, thumb2 (행 2, col1) title3, thumb3 (행 2, col2) title4, thumb4 .... itemsSource를 목록 상자에 어떻게 연결할 수 있습니까? – ttotto

+0

Nucleons가 당신을 위해 그것을 만들었습니다. 랩 패널은 크기가 좋은 경우 세 번째 항목을 두 번째 줄에 배치합니다. 예를 들어, 목록 상자의 너비가 480이고 항목의 너비가 240 인 경우를 예로들 수 있습니다. –

+0

ItemWidth = ""및 ItemHeight = ""를 wrappanel로 설정하십시오. – nucleons