完成添加变量对话框验证
This commit is contained in:
@@ -9,6 +9,7 @@ public partial class VariableDialog
|
||||
{
|
||||
private const int ContentAreaMaxWidth = 1200;
|
||||
private const int ContentAreaMaxHeight = 900;
|
||||
|
||||
public VariableDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -20,7 +21,21 @@ public partial class VariableDialog
|
||||
var backgroundElementBorder = VisualTreeFinder.FindVisualChildByName<Border>(this, "BackgroundElement");
|
||||
backgroundElementBorder.MaxWidth = ContentAreaMaxWidth;
|
||||
backgroundElementBorder.MaxWidth = ContentAreaMaxHeight;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
// 获取ViewModel
|
||||
if (DataContext is VariableDialogViewModel viewModel)
|
||||
{
|
||||
// 调用ViewModel的PrimaryButtonAsync方法
|
||||
bool isValid = await viewModel.PrimaryButtonAsync();
|
||||
|
||||
// 如果验证失败,取消对话框关闭
|
||||
if (!isValid)
|
||||
{
|
||||
args.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user