DynamicContentDialog.xaml.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System.Windows;
  2. using NPOI.OpenXmlFormats.Spreadsheet;
  3. namespace InABox.DynamicGrid;
  4. public partial class DynamicContentDialog : Window
  5. {
  6. public static readonly DependencyProperty CanSaveProperty = DependencyProperty.Register(nameof(CanSave), typeof(bool), typeof(DynamicContentDialog));
  7. public bool ButtonsVisible
  8. {
  9. get => Buttons.Visibility == Visibility.Visible;
  10. set => Buttons.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
  11. }
  12. public bool CanSave
  13. {
  14. get => (bool)GetValue(CanSaveProperty);
  15. set => SetValue(CanSaveProperty, value);
  16. }
  17. public DynamicContentDialog(FrameworkElement element, bool buttonsvisible = true)
  18. {
  19. InitializeComponent();
  20. ButtonsVisible = buttonsvisible;
  21. Presenter.Content = element;
  22. }
  23. private void OKButton_Click(object sender, RoutedEventArgs e)
  24. {
  25. DialogResult = true;
  26. }
  27. private void CancelButton_Click(object sender, RoutedEventArgs e)
  28. {
  29. DialogResult = false;
  30. }
  31. }