2011-03-03 6 views
2

특정 너비의 ListBox가있는 Silverlight 응용 프로그램이 있습니다. 내 코드 숨김에이 ListBox에 항목을 동적으로 추가하고 있습니다. 항목에 할당 된 것보다 많은 공간이 필요한 경우 항목을 다음 줄로 감싸고 ListBox의 높이를 늘리고 싶습니다. 이제 실행되면 가로 스크롤 막대가 내 ListBox에 나타납니다. 또한 랩핑이 없으므로 성장이 일어나지 않습니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까? 여기 내 ListBox가 있습니다 :Silverlight의 ListBox에서 WrapPanel 사용

<ListBox x:Name="myListBox" Grid.Column="1" Width="600" MinHeight="24"> 
    <ListBox.ItemsPanel> 
    <ItemsPanelTemplate> 
     <controlsToolkit:WrapPanel /> 
    </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 
</ListBox> 

감사합니다!

답변

10

ListBox에서 ScrollViewer.HorizontalScrollBarVisibility를 Disabled로 설정하여 가로 스크롤을 방지하고 줄 바꿈을 수행하십시오.

<ListBox x:Name="myListBox" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.Column="1" Width="600" MinHeight="24"> 
    <ListBox.ItemsPanel> 
     <ItemsPanelTemplate> 
      <controlsToolkit:WrapPanel /> 
     </ItemsPanelTemplate> 
    </ListBox.ItemsPanel> 
</ListBox>