ContentDialog
のデフォルトの動作は、PCを中心にしてモバイルで一番上になるようにする必要がありますが、私の場合はPCでも何が起こっているのか理解していない。ContentDialogがUWPのセンターにアラインメントしていません
私はコードビハインド使用してそれを作成していますが、これは私が使用しているコードの抜粋です:
// Creates the password box
var passwordBox = new PasswordBox {IsPasswordRevealButtonEnabled = true, Margin = new Thickness(5)};
// Creates the StackPanel with the content
var contentPanel = new StackPanel();
contentPanel.Children.Add(new TextBlock
{
Text = "Insert your password to access the application",
Margin = new Thickness(5),
TextWrapping = TextWrapping.WrapWholeWords
});
contentPanel.Children.Add(passwordBox);
// Creates the password dialog
_passwordDialog = new ContentDialog
{
PrimaryButtonText = "accept",
IsPrimaryButtonEnabled = false,
SecondaryButtonText = "exit",
Title = "Authentication",
Content = contentPanel
};
// Report that the dialog has been opened to avoid overlapping
_passwordDialog.Opened += (s, e) =>
{
// HACK - opacity set to 0 to avoid seeing behind dialog
Window.Current.Content.Opacity = 0;
_canShowPasswordDialog = false;
};
// Report that the dialog has been closed to enable it again
_passwordDialog.Closed += (s, e) =>
{
// HACK - opacity set to 1 to reset the window to original options
Window.Current.Content.Opacity = 1;
_canShowPasswordDialog = true;
};
// Clear inserted password for next logins
_passwordDialog.PrimaryButtonClick += (s, e) =>
{
// ... login ...
};
// Close the app if the user doesn't insert the password
_passwordDialog.SecondaryButtonClick += (s, e) => { BootStrapper.Current.Exit(); };
// Set the binding to enable/disable the accept button
_passwordDialog.SetBinding(ContentDialog.IsPrimaryButtonEnabledProperty, new Binding
{
Source = passwordBox,
Path = new PropertyPath("Password"),
Mode = BindingMode.OneWay,
Converter = new PasswordValidatorConverter()
});
私はすでにVerticalAlignment
とFullSizeDesired
を使用してみましたが、私は期待得ることはありません結果。
どうすればこの問題を解決できますか?
を参照してください。 –