Files
DMS/DMS.WPF/Views/Dialogs/VariableDialog.xaml.cs

42 lines
1.2 KiB
C#
Raw Normal View History

using DMS.WPF.Helper;
2025-08-23 16:01:30 +08:00
using DMS.WPF.ViewModels.Dialogs;
using iNKORE.UI.WPF.Modern.Controls;
using System.Windows.Controls;
2025-08-23 16:01:30 +08:00
namespace DMS.WPF.Views.Dialogs;
public partial class VariableDialog
{
2025-08-24 12:25:44 +08:00
private const int ContentAreaMaxWidth = 1200;
private const int ContentAreaMaxHeight = 900;
2025-08-24 17:01:33 +08:00
2025-08-24 14:42:31 +08:00
2025-08-23 16:01:30 +08:00
public VariableDialog()
{
InitializeComponent();
this.Opened += OnOpened;
}
private void OnOpened(ContentDialog sender, ContentDialogOpenedEventArgs args)
{
var backgroundElementBorder = VisualTreeFinder.FindVisualChildByName<Border>(this, "BackgroundElement");
backgroundElementBorder.MaxWidth = ContentAreaMaxWidth;
backgroundElementBorder.MaxWidth = ContentAreaMaxHeight;
2025-08-23 16:01:30 +08:00
}
2025-08-24 14:42:31 +08:00
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;
}
}
}
2025-08-23 16:01:30 +08:00
}