2012-07-10 4 views
0

목록 상자 안에있는 스택 패널 안에 그리드가 있습니다. 이 그리드에는 사각형과 텍스트 블록과 같은 몇 가지 컨트롤 요소가 있습니다. 가로로 세로로 늘리지 만 세로로는 늘리지 않습니다.방향 변경 후 목록 상자 안의 컨트롤의 너비가 변경되지 않습니다.

<ListBox Name="PassList" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> 

         <ListBox.ItemTemplate> 
          <DataTemplate> 
           <StackPanel HorizontalAlignment="Stretch"> 
            <Grid Name="StackPanelWidth" Width="{Binding ElementName=PassList, Path=ActualWidth}"> 
             <Grid.RowDefinitions> 
              <RowDefinition Height="40"/> 
              <RowDefinition Height="40"/> 
              <RowDefinition Height="40"/> 
              <RowDefinition Height="40"/> 
              <RowDefinition Height="20"/> 
             </Grid.RowDefinitions> 
             <Grid.ColumnDefinitions> 
              <ColumnDefinition Width="10"/> 
              <ColumnDefinition Width="{Binding ElementName=StackPanelWidth, Path=ActualWidth}"/> 
              <ColumnDefinition Width="10"/> 
             </Grid.ColumnDefinitions> 

             <Rectangle Fill="White" 
                Grid.Row="0" 
                Grid.Column="1" 
                HorizontalAlignment="Stretch" 
                VerticalAlignment="Stretch" 
                RadiusX="10" 
                RadiusY="10" 
                /> 

             <Rectangle Fill="White" 
                Grid.Row="0" 
                Grid.Column="1" 
                HorizontalAlignment="Stretch" 
                VerticalAlignment="Stretch" 
                Margin="0,10,0,0" 
                /> 

             <Rectangle Fill="DarkGray" 
                Grid.Row="0" 
                Grid.Column="1" 
                Height="1" 
                VerticalAlignment="Bottom" 
                /> 

             <TextBlock Name="Country" 
                Grid.Row="0" 
                Grid.Column="1" 
                HorizontalAlignment="Left" 
                Margin="10,0,0,0" 
                VerticalAlignment="Center" 
                Text="{Binding Country}" 
                Foreground="Black" 
                FontWeight="Bold" 
                /> 


             ............. 
             ............. 

            </Grid> 
           </StackPanel> 
          </DataTemplate> 
         </ListBox.ItemTemplate> 
        </ListBox> 

내 코드를 잘못 어떤 일이 있습니까 :

Snapshot of emulator

는 XAML입니까? 도움이 될 것입니다.

감사합니다.

답변

0

왜이 작업을 수행하고 있습니까?

< Grid.ColumnDefinitions> < ColumnDefinition 폭 = "10"/> < ColumnDefinition 폭 = "{ElementName에 바인딩 = StackPanelWidth, 패스 = ActualWidth}"/> < ColumnDefinition 폭 = "10"/> < /Grid.ColumnDefinitions>

여기서 너는 크기를 조정하지 않아서 너비를 지정합니다.

또한 스택 패널은 자동으로 하위 너비로 조정되므로 수행하려는 작업이 있다면 바인딩을 지정할 필요가 없습니다.

관련 문제