Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 网格中的StackPanel:限制高度_C#_Xaml_Layout_Winrt Xaml - Fatal编程技术网

C# 网格中的StackPanel:限制高度

C# 网格中的StackPanel:限制高度,c#,xaml,layout,winrt-xaml,C#,Xaml,Layout,Winrt Xaml,我有一个大的主网格,有几行和几列。我想在其中一个单元格中放置一个垂直堆叠面板。在这个stackpanel中有一个textblock和一个scrollviewer。我的问题是,stackpanel不受单元格的限制,相反,stackpanel变得足够大,可以容纳整个scrollviewer 我怎样才能解决这个问题 编辑:我的xaml代码: <Grid x:Name="Grid1" Margin="120,0,0,0" Width="1244"> &

我有一个大的主网格,有几行和几列。我想在其中一个单元格中放置一个垂直堆叠面板。在这个stackpanel中有一个textblock和一个scrollviewer。我的问题是,stackpanel不受单元格的限制,相反,stackpanel变得足够大,可以容纳整个scrollviewer

我怎样才能解决这个问题

编辑:我的xaml代码:

<Grid x:Name="Grid1" Margin="120,0,0,0" Width="1244">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="0*"/>
                        <ColumnDefinition Width="33*"/>
                        <ColumnDefinition Width="40"/>
                        <ColumnDefinition Width="50*"/>
                        <ColumnDefinition Width="40"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="71"/>
                        <RowDefinition Height="40"/>
                        <RowDefinition/>
                        <RowDefinition Height="20"/>
                    </Grid.RowDefinitions>
                    <StackPanel Grid.Column="3" Grid.Row="2" Grid.ColumnSpan="2" Margin="0">
                        <TextBlock TextWrapping="Wrap" FontSize="48" Margin="0" VerticalAlignment="Top" Foreground="#FF0083FF" Text="Top 10:" HorizontalAlignment="Left" FontFamily="Segoe UI Light"/>
                        <ScrollViewer Margin="0,20,0,0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">
                            <StackPanel>
                                <ListView x:Name="TopListView" ItemsSource="{Binding}" SelectionMode="None" Foreground="White" >
                                    <ListView.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <StackPanel >
                                                    <TextBlock FontSize="32" Text="1" Foreground="#FF0083FF"/>
                                                </StackPanel>
                                                <TextBlock Text="{Binding Text}" Foreground="Black" 
                                                    FontSize="16" Margin="0,0,0,0" TextWrapping="Wrap" />

                                            </StackPanel>
                                        </DataTemplate>
                                    </ListView.ItemTemplate>
                                </ListView>
                            </StackPanel>
                        </ScrollViewer>
                    </StackPanel>

                </Grid>

使用另一个网格而不是StackPanel:

<Grid Grid.Column="3" Grid.Row="2" Grid.ColumnSpan="2" Margin="0">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <TextBlock FontSize="48" FontFamily="Segoe UI Light"
               Foreground="#FF0083FF" HorizontalAlignment="Left"
               TextWrapping="Wrap" Text="Top 10:"/>
    <ScrollViewer Grid.Row="1" Margin="0,20,0,0"
                  HorizontalScrollBarVisibility="Disabled"
                  VerticalScrollBarVisibility="Visible">
        ...
    </ScrollViewer>
</Grid >

使用另一个网格而不是StackPanel:

<Grid Grid.Column="3" Grid.Row="2" Grid.ColumnSpan="2" Margin="0">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition/>
    </Grid.RowDefinitions>
    <TextBlock FontSize="48" FontFamily="Segoe UI Light"
               Foreground="#FF0083FF" HorizontalAlignment="Left"
               TextWrapping="Wrap" Text="Top 10:"/>
    <ScrollViewer Grid.Row="1" Margin="0,20,0,0"
                  HorizontalScrollBarVisibility="Disabled"
                  VerticalScrollBarVisibility="Visible">
        ...
    </ScrollViewer>
</Grid >

展示你的工作并告诉人们你尝试了什么添加代码:我尝试了很多,但还没有找到解决方案Yes展示你的工作并告诉人们你尝试了什么添加代码:我尝试了很多,但还没有找到解决方案