문제

Windows 8.1 응용 프로그램 (.NET 4.5)에서는 ListView가 포함 된 스택 패널이 포함 된 그리드가있는 그리드입니다. 목록보기는 사용 가능한 공간으로 확장되지 않습니다. 대신 스크롤 막대를 표시합니다.

<Grid DataContext="{Binding}">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/> <!-- IF I set MinHeight here, it grows -->
    </Grid.RowDefinitions>
    <TextBlock Grid.Row="0"/>
    <ListView
            Grid.Row="1"
            Margin="10"
            ItemsSource="{Binding ementas}"
            ItemTemplate="{StaticResource temp1}"
            SelectionMode="None"
            IsItemClickEnabled="False"
            IsSwipeEnabled="False">
    </ListView>
</Grid>
.

listview의 템플릿

<StackPanel Width="310" Margin="5,10,5,10" DataContext="{Binding}">
    <TextBlock Text="{Binding data}" Style="{StaticResource TitleTextBlockStyle}"/>
    <ListView SelectionMode="None"
            IsItemClickEnabled="False"
            ItemsSource="{Binding pratos}"
            ItemTemplate="{StaticResource temp2}"
            IsSwipeEnabled="False">
    </ListView>
</StackPanel>
.

및 두 번째 ListView의 템플릿

<TextBlock Text="{Binding descricao}"
    Margin="5"
    Style="{StaticResource BodyTextBlockStyle}"
    TextWrapping="WrapWholeWords"/>
.

스크린 샷 : screenshot

스크롤 막대가 콘텐츠에 맞게 크기 스케일이있는 ListView를 원하시면 화면 공간이 부족한 경우에만 스크롤합니다.

도움이 되었습니까?

해결책

이것은 매우 공통적 인 문제점입니다 ... StackPanel not Grid처럼 부모 컨트롤에 맞게 내용을 조정하지 않습니다.솔루션은 간단합니다 ... 일부 컨트롤 업무를 제외한 가장 간단한 단순한 간단한 것을 제외하고는 StackPanel를 사용하지 마십시오.이 대신에 Grid를 사용하여 상위 컨트롤에서 제공하는 모든 공간에 자동으로 적합합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top