3

このコードを新しい UWP アプリのメインページに貼り付ける (または最初の画像を見る) と、オレンジ色のグリッドが必要以上のスペースを占めていることがわかります (VerticalAlignmentが一番上に設定されています)。正常に動作させるには、このグリッドの 2 行目の高さを に設定する必要がありますAuto(2 番目の図を参照)。問題は、2 行目/最後の行に余分なスペースを与え、すべての行に分散させたくないということです。
独自のグリッド内の左の列にコントロールを配置すると (明らかに、行スパンがないため)、画面が狭くなると右の列のスタックパネルが左の列の行の中に入るため、それはできません。

2 つ目の問題は、オレンジ/グリーン/イエローのスペースをクリックすると、フォーカスが常に最初の行 (イエロー) のテキスト ボックスに移動することです。

更新:両方の問題はスクロールビューアーなしで修正されますが、明らかに必要です。


<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <ScrollViewer Background="DarkGreen" VerticalScrollBarVisibility="Auto">
        <Grid Background="DarkOrange" Margin="10" VerticalAlignment="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <StackPanel Grid.Row="0" Background="Yellow">
                <TextBlock Text="Title" />
                <TextBox Margin="20" />
            </StackPanel>
            <Grid Grid.Row="1" Background="DeepPink" VerticalAlignment="Top">
                <ListView Margin="10" VerticalAlignment="Top">
                    <ListView.Items>
                        <TextBlock Text="Item1" />
                    </ListView.Items>
                </ListView>
            </Grid>
            <StackPanel Grid.Column="1" Grid.RowSpan="2" Background="Blue" VerticalAlignment="Top">
                <StackPanel>
                    <TextBlock Text="Title1" />
                    <GridView Margin="0,10,0,0">
                        <GridView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <ItemsWrapGrid Orientation="Horizontal" MaximumRowsOrColumns="4" />
                            </ItemsPanelTemplate>
                        </GridView.ItemsPanel>
                        <GridView.Items>
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                        </GridView.Items>
                    </GridView>
                </StackPanel>
                <StackPanel>
                    <TextBlock Text="Title2" />
                    <GridView Margin="0,10,0,0">
                        <GridView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <ItemsWrapGrid Orientation="Horizontal" MaximumRowsOrColumns="4" />
                            </ItemsPanelTemplate>
                        </GridView.ItemsPanel>
                        <GridView.Items>
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                            <Rectangle Width="80" Height="80" Fill="White" />
                        </GridView.Items>
                    </GridView>
                </StackPanel>
            </StackPanel>
        </Grid>
    </ScrollViewer>
</Grid>

行スパン

4

1 に答える 1

0

回避策を見つけました。最初の行は拡張または変更されないため、最初の行のMaxHeightプロパティを実行時の行の実際の高さと等しくなるように設定します。

2 番目の問題については、httpsIsTabStop : //social.msdn.microsoft.com/Forums/windowsapps/en-US/32e026dd-8338-4c19-a7d6-1bb8797044b3/first-input-control でTrue説明されているように、スクロールビューアーのプロパティを設定します。
-in-the-scroll-viewer-is-always-getting-focused?prof=必須

于 2016-04-25T20:42:33.280 に答える