2011-04-06 2 views
0

listBox의 항목을 가로로 늘리 겠지만 항목의 내용이 목록 상자보다 크면 가로 스크롤 막대가 나타납니다. 이것을 피하는 방법?문제 설정 ListBox의 DataTemplate에서 HorizontalAligment = "Stretch"

XAML :

<Window x:Class="WpfApplication6.MainWindow" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
     Title="MainWindow" Height="350" Width="525"> 
    <Window.Resources> 
     <DataTemplate x:Key="testTemplate"> 
      <Border x:Name="border" 
        BorderBrush="Black" 
        BorderThickness="1" 
        Margin="2" 
        Padding="2" 
        HorizontalAlignment="Stretch"> 
       <TextBlock Text="{Binding}" /> 
      </Border> 
     </DataTemplate> 
    </Window.Resources> 
    <Grid> 
     <ListBox x:Name="listBox" 
       VerticalAlignment="Stretch" 
       HorizontalAlignment="Stretch" 
       HorizontalContentAlignment="Stretch" 
       ItemTemplate="{StaticResource testTemplate}" /> 
    </Grid> 
</Window> 

답변

2

설정 ScrollViewer.HorizontalScrollBarVisibilityDisabled에 :

<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled"> 
    ... 
</ListBox> 
관련 문제