XAML在可滚动区域顶部固定横幅

XAML在可滚动区域顶部固定横幅,xaml,Xaml,我正试图在我的页面上添加一个固定在窗口中的横幅,我现在很难过 这就是我试图实现的目标:我想要一个横幅,漂浮在窗口顶部的广告,然后我想要在一个可滚动的区域中的其余内容。第一项应该是文本块,然后是文本框,然后是按钮 这是我现在得到的代码,除了滚动之外,它看起来是正确的。我们将不胜感激 <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.mi

我正试图在我的页面上添加一个固定在窗口中的横幅,我现在很难过

这就是我试图实现的目标:我想要一个横幅,漂浮在窗口顶部的广告,然后我想要在一个可滚动的区域中的其余内容。第一项应该是文本块,然后是文本框,然后是按钮

这是我现在得到的代码,除了滚动之外,它看起来是正确的。我们将不胜感激

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

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <StackPanel Grid.RowSpan="3">
            <Universal:AdMediatorControl x:Name="AdMediatorName" Height="90" Id="AdMediator-Id" Margin="10,0"/>
            <ScrollViewer x:Name="myScrollViewer"  VerticalScrollMode="Enabled">
                <StackPanel Grid.RowSpan="2">
                    <TextBlock x:Name ="outputConsole" FontSize="15" RenderTransformOrigin="0.5,0" TextWrapping="WrapWholeWords" Margin="0,0,10,0" FontFamily="Consolas" IsTextSelectionEnabled="True">
                        <TextBlock.RenderTransform>
                            <CompositeTransform/>
                        </TextBlock.RenderTransform>
                        <TextBlock.Projection>
                            <PlaneProjection/>
                        </TextBlock.Projection>
                        <Run/>
                        <LineBreak/>
                        <Run/>
                    </TextBlock>
                    <TextBox x:Name="inputConsole" FontSize="20" KeyUp="inputKeyUp" Margin="0,0,10,0" FontFamily="Consolas" IsTapEnabled="True" IsTextPredictionEnabled="True"/>
                    <Button x:Name="submitButton" Content="Submit" Click="submitButtonClick"/>
                </StackPanel>
            </ScrollViewer>
        </StackPanel>

    </Grid>
</Page>

我想出来了。我只需要把它直接放到网格中。抱歉,仍在学习XAML。

您刚刚回答了您的问题。你必须这样做

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

    <StackPanel Grid.Row="0" Orientation="Horizontal"><TextBlock x:Name ="outputConsole" FontSize="15" RenderTransformOrigin="0.5,0" TextWrapping="WrapWholeWords" Margin="0,0,10,0" FontFamily="Consolas" IsTextSelectionEnabled="True">
                    <TextBlock.RenderTransform>
                        <CompositeTransform/>
                    </TextBlock.RenderTransform>
                    <TextBlock.Projection>
                        <PlaneProjection/>
                    </TextBlock.Projection>
                    <Run/>
                    <LineBreak/>
                    <Run/>
                </TextBlock>
                <TextBox x:Name="inputConsole" FontSize="20" KeyUp="inputKeyUp" Margin="0,0,10,0" FontFamily="Consolas" IsTapEnabled="True" IsTextPredictionEnabled="True"/>
                <Button x:Name="submitButton" Content="Submit" Click="submitButtonClick"/>
    </StackPanel>  

    <ScrollViewer Grid.Row="1">

    </ScrollViewer>