2016-10-19 2 views
1

나는 두 DataGrids를 가지고 (데이터 그리드 (1) 및 2) 별도의 사용자 정의 컨트롤에서 행되고있는 :WPF DataGrid에 높이가 무한

 <Grid Grid.Row="1"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="auto"/> 
      <RowDefinition Height="*"/> 
     </Grid.RowDefinitions> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="*" /> 
      <ColumnDefinition Width="auto" /> 
     </Grid.ColumnDefinitions> 

     <Grid Grid.Row="0" Grid.Column="0" >    
     <local:DATAGRID1 x:Name="DATAGRID1" /></Grid> 

     <Grid Grid.Row="1" Grid.Column="0"> 
     <local:DATAGRID2 x:Name="DATAGRID2" /> </Grid> 

     <Grid Grid.Row="0" x:Name="AddURLContainer" Grid.Column="1" > 
      <StackPanel> 
      <local:test1 x:Name="NewQueryControl"/> 
      <local:test2 x:Name="AddURLControl" /> 
      </StackPanel> 

     </Grid> 
     </Grid> 

하지만 데이터 그리드가 더 이상 창을 돈보다는 스트레칭 몇 가지 이유 창문 높이 내에서 제약을받지 않습니다. 스크롤 뷰어에 Datagrid를 넣으려고 시도했지만 스크롤 막대도 창 밖으로 나가 제한하지 않습니다. 나는 왜이 일을하는지 알 수 없다. 실제 데이터 그리드의 오프닝 태그는 (그리고 그들은 사용자 제어하지 않는 Stackpannel에 싸여있다) :

<DataGrid AutoGenerateColumns="False" 
      IsReadOnly="True" 
      SelectionMode="Single" 
      > 

답변

0

왜 * 폭과 heigt을 사용하고 있습니까?

사용 자동 :이 내용을 할당 해 있음

<Grid.RowDefinitions> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="Auto" /> 
     <ColumnDefinition Width="Auto" /> 
    </Grid.ColumnDefinitions> 

자동 크기를 설정합니다.

<Grid.RowDefinitions> 
     <RowDefinition Height="50"/> 
     <RowDefinition Height="auto" /> 
    </Grid.RowDefinitions> 

하려면 :

<Grid.RowDefinitions> 
     <RowDefinition Height="50"/> 
     <RowDefinition Height="*" /> 
    </Grid.RowDefinitions> 

이상한 수정을하지만 작동 난에서 위의 주요 그리드 행 속성을 변경하는 경우

+0

"AddURLContainer"의 내용이 접힌 패널로 토글되기 때문에 열 너비가 *로 설정됩니다. 비록 내가 그것들을 모두 자동으로 가지고 있어도 여전히 창 안의 데이터 그리드를 제한하지는 않지만 데이터 그리드는 여전히 오버플로합니다. – Whirlwind991

+0

무엇에 오버플로가 있습니까? "AddURLContainer"에? – Rom

+0

주 창 외부로 오버플로됩니다. 당신은 실제로 저에게 아이디어를 주었고 저는 주된 부모 컨테이너를 확인하고 높이를 'auto'에서 '*'로 변경하여 이상하게도 이상하게 ... 당신이 말하는 것처럼 자동차는 *보다 효과적이었습니다 * – Whirlwind991