【发布时间】:2017-04-07 14:18:18
【问题描述】:
在我的ContentDialog 中,我有一个StackPanel,带有大约三个控件(垂直方向)。我的问题是 ContentDialog 的高度一直延伸到窗口的底部,即使它的内容甚至不占据它的一半。
我猜测这可能是StackPanel 的问题,但是我该如何解决这个问题?
我可以设置一个MaxHeight,但我必须用每个ContentDialog 不同的固定值填充它...
更新
这是在 MainPage.xaml(VS UWP 模板的默认起始页)中。 XAML 仅显示了一个用例按钮的创建,在 Click 事件中:
private async void Button_Click(object sender, RoutedEventArgs e)
{
DataEntryDialog dialog = new DataEntryDialog();
//Show dialog
await dialog.ShowAsync();
}
DataEntryDialog.xaml:
<ContentDialog
x:Class="App1.Dialogs.UserAccountDataEntryDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="TITLE"
PrimaryButtonText="Save"
SecondaryButtonText="Cancel"
Loaded="ContentDialog_Loaded"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick">
<StackPanel>
<TextBox Header="Username" Margin="0,20,0,0"/>
<PasswordBox Header="Password" Margin="0,12,0,0"/>
<CheckBox Content="Active" Margin="0,12,0,0"/>
</StackPanel>
</ContentDialog>
【问题讨论】: