【问题标题】:XAML fixed banner on top of scrollable areaXAML 将横幅固定在可滚动区域的顶部
【发布时间】:2015-12-01 17:21:41
【问题描述】:

我正在尝试将在窗口中保持固定的横幅添加到我的页面,但我遇到了困难。

这就是我想要实现的目标:我想要一个浮动在窗口顶部的横幅(用于广告),然后我想要将其余内容放在可滚动区域中。第一项应该是 textBlock,然后是 textBox,然后是按钮。

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

<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


    【解决方案1】:

    我想通了。我只需要将它直接放入网格中。抱歉,还在学习 XAML。

    【讨论】:

      【解决方案2】:

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

          <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>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多