次のコードを使用してポップアップを作成しましたが、中央に配置する方法がわかりません
実行時に自動的に余白を変更しようとしましたが、誰かがポップアップをどのように中央に置くかという考えを持っていますか?
それはそれが言うように、私は以下のuser1603313の答えを試みたが、それはトリックをしなかった私は私のプログラムXAMLの中央ポップアップ
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Name="MainGrid">
<Popup x:Uid="LoginPopup" IsOpen="True" Name="LoginPopup">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Margin="10" Grid.Column="0" Grid.Row="0" Text="App Name" Grid.ColumnSpan="2" Style="{StaticResource HeaderTextStyle}" />
<TextBlock Margin="10" Grid.Column="0" Grid.Row="1" Text="Username" Style="{StaticResource ResourceKey=SubheaderTextStyle}" />
<TextBox Margin="10" Grid.Column="1" Grid.Row="1" Name="InputUsername" />
<TextBlock Margin="10" Grid.Column="0" Grid.Row="2" Text="Password" Style="{StaticResource ResourceKey=SubheaderTextStyle}" />
<PasswordBox Margin="10" Grid.Column="1" Grid.Row="2" Name="InputPassword" />
<StackPanel Margin="10" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Left" Orientation="Horizontal">
<Button Name="Login" x:Uid="LoginPopupLogin" />
<Button Name="Cancel" x:Uid="LoginPopupCancel" />
</StackPanel>
</Grid>
</Popup>
</Grid>
UPDATE
をグローバル化する必要があり、標準的な寸法原因がありませんポップアップ内のグリッドのサイズはNaNです。
は、私はまた、グリッドにメソッドを移動しようとしたが、それはトリックをしなかったのどちらか、私が話しています方法はここ
private void LoginPopup_Loaded_1(object sender, RoutedEventArgs e)
{
LoginPopup.HorizontalOffset = (Window.Current.Bounds.Width - gdChild.ActualWidth)/2;
LoginPopup.VerticalOffset = (Window.Current.Bounds.Height - gdChild.ActualHeight)/2;
}
にそのメソッドを呼び出すことができているあなたは、フライアウトと思われます。 http://msdn.microsoft.com/en-us/library/windows/apps/hh465354.aspx –
@SinanErgin私が読んだように、フライアウトはHTML – The87Boy
ああのためだけです、それは本当です。フライアウトは使用できませんxaml + c#/ vb。良い仕事;) –