2016-11-19 25 views
2

这是我的UAMP页面的XAML。不占用整个页面的网格UWP

<Page 
x:Class="App.AddComment" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:local="using:App" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="d" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" 
> 
<Page.BottomAppBar> 
    <CommandBar> 
     <CommandBar.Content> 
      <Grid/> 
     </CommandBar.Content> 
     <AppBarButton Icon="PostUpdate" Label="Post"/> 
    </CommandBar> 
</Page.BottomAppBar> 

<StackPanel Margin="5,10,5,50" BorderBrush="Black" BorderThickness="3" Background="White" HorizontalAlignment="Stretch"> 
    <TextBlock Name="Title" HorizontalAlignment="Stretch" Margin="10" MinHeight="50" TextTrimming="CharacterEllipsis" TextWrapping="Wrap" Foreground="{StaticResource SystemControlBackgroundAccentBrush}" FontWeight="Normal" FontSize="20"/> 
    <TextBox Name="CommentBox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,20,10,20" AcceptsReturn="True" TextWrapping="Wrap" FontWeight="Thin" FontSize="18" VerticalContentAlignment="Stretch" Height="200" Header="Comment" PlaceholderText="Enter your comment here.."/> 
</StackPanel> 

但StackPanel中并不占据整个页面(宽).. 即使我设置Horizo​​ntalContentAlignment和HorizantalAlignment为STRECH,它不工作.. 我甚至试过位发车的StackPanel,但问题仍然存在。 Please see the image

+1

摆脱保证金。这是导致问题的原因 – AbsoluteSith

回答

1

它看起来是您的StackPanel包装页面内容上有一个边缘。

保证金导致控件的缝隙添加到控件外部使其具有推入这个样子的:

Margin/Current look

你可能想要做的是去除余量,如果它是不需要,或将其更改为填充。

<StackPanel Padding="5,10,5,50" BorderBrush="Black" BorderThickness="3" Background="White" HorizontalAlignment="Stretch"> 
    <TextBlock Name="Title" HorizontalAlignment="Stretch" Margin="10" MinHeight="50" TextTrimming="CharacterEllipsis" TextWrapping="Wrap" Foreground="{StaticResource SystemControlBackgroundAccentBrush}" FontWeight="Normal" FontSize="20"/> 
    <TextBox Name="CommentBox" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,20,10,20" AcceptsReturn="True" TextWrapping="Wrap" FontWeight="Thin" FontSize="18" VerticalContentAlignment="Stretch" Height="200" Header="Comment" PlaceholderText="Enter your comment here.."/> 
</StackPanel> 

一个填充造成的差距,出现这样的控件中:

Padding look

这给你里面的内容相同的布局,但将有边缘到边缘看你想要StackPanel/Grid。

相关问题