mirror of
https://github.com/ckaczor/FloatingStatusWindow.git
synced 2026-03-11 03:51:38 -04:00
Add template project
This commit is contained in:
41
Template/SettingsWindow/ItemWindow.xaml.cs
Normal file
41
Template/SettingsWindow/ItemWindow.xaml.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using ChrisKaczor.Wpf.Validation;
|
||||
|
||||
namespace Template.SettingsWindow;
|
||||
|
||||
public partial class ItemWindow
|
||||
{
|
||||
public ItemWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public bool? Display(ItemEntry itemEntry, Window owner)
|
||||
{
|
||||
DataContext = itemEntry;
|
||||
|
||||
Title = string.IsNullOrWhiteSpace(itemEntry.Name) ? Properties.Resources.ItemWindowAdd : Properties.Resources.ItemWindowEdit;
|
||||
|
||||
Owner = owner;
|
||||
|
||||
return ShowDialog();
|
||||
}
|
||||
|
||||
private void HandleOkayButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!this.IsValid())
|
||||
return;
|
||||
|
||||
var item = (ItemEntry)DataContext;
|
||||
|
||||
if (!Data.ItemEntries.Contains(item))
|
||||
Data.ItemEntries.Add(item);
|
||||
|
||||
Data.Save();
|
||||
|
||||
DialogResult = true;
|
||||
|
||||
Close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user