0

我有一个看起来像这样的代码

<Popup IsOpen="True" Margin="200" Height="260" Width="900">
   <Grid Height="250">
      <TextBlock Style="{StaticResource HeaderTextStyle}" Text="Login" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Top" Height="50" />
      <TextBlock Style="{StaticResource ResourceKey=SubheaderTextStyle}" Text="" Margin="0,63,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" />
      <TextBox Name="InputUsername" Margin="0,63,0,0" HorizontalAlignment="Right" Height="40" Width="650"/>
      <TextBlock Style="{StaticResource ResourceKey=SubheaderTextStyle}" Text="" Margin="0,138,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>
      <PasswordBox Name="InputPassword" Margin="0,0,138,0" HorizontalAlignment="Right" VerticalAlignment="Top" Height="40" Width="650"  />
      <Button Name="Login" Content="" Margin="200,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Bottom"  />
      <Button Name="Cancel" x:Uid="LoginPopupCancel" Content="" Margin="300,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
   </Grid>
</Popup>

但它不起作用,当我旋转屏幕时,会出现什么问题?

更新

<Grid>
   <Grid.RowDefinitions>
      <RowDefinition Height="100" />
      <RowDefinition Height="100" />
   </Grid.RowDefinitions>
   <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto"/>
      <ColumnDefinition Width="*"/>
   </Grid.ColumnDefinitions>
   <TextBlock Style="{StaticResource ResourceKey=SubheaderTextStyle}" Text="Brugernavn" />
   <TextBox Name="InputUsername" />
   <TextBlock Style="{StaticResource ResourceKey=SubheaderTextStyle}" Text="Adgangskode" />
   <PasswordBox Name="InputPassword" />
</Grid>

我正在尝试找到一个修复程序,但这会将所有框和块设置在彼此下方,我该如何解决这个问题?
D'oh 我忘了设置 Grid.Column 和 Grid.Row

4

1 回答 1

1

您需要为 Portrait 视图添加一个 Visual State,并在其中处理 Popup 元素的位置。

<VisualState x:Name="FullScreenPortrait">
                <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Margin"> <!--Example-->
                        <DiscreteObjectKeyFrame KeyTime="0" Value="0,0,0,0"/>
                    </ObjectAnimationUsingKeyFrames>
                </Storyboard>
            </VisualState>

您需要针对每个组件调整边距,使其适合并看起来不错。否则,您可以只支持横向视图,您的问题就结束了。

于 2012-12-16T20:01:15.733 回答