2015-09-05 120 views
0

我试图添加一个横幅,该窗口仍然固定在我的页面的窗口中,而且我的时间很艰难。XAML在可滚动区域顶部固定的横幅

这就是我想要实现的:我想要一个浮动在窗口顶部(对于广告)的横幅,然后我需要其他内容在可滚动区域。第一项应该是一个textBlock,然后是一个文本框,然后是一个按钮。

http://i.imgur.com/uJiD1wE.png

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

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

回答

0

我想通了。我只需要把它直接放在网格中。对不起,仍在学习XAML。

0

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

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