47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using System.Linq;
|
|
using Avalonia;
|
|
using Avalonia.Controls.ApplicationLifetimes;
|
|
using Avalonia.Data.Core.Plugins;
|
|
using Avalonia.Markup.Xaml;
|
|
using Zurnal_Vizual.Views.MainWindow;
|
|
|
|
namespace Zurnal_Vizual
|
|
{
|
|
public partial class App : Application
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
}
|
|
|
|
public override void OnFrameworkInitializationCompleted()
|
|
{
|
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
|
{
|
|
DisableAvaloniaDataAnnotationValidation();
|
|
|
|
var mainWindow = new MainWindow
|
|
{
|
|
DataContext = new MainViewModel(),
|
|
};
|
|
|
|
desktop.MainWindow = mainWindow;
|
|
}
|
|
|
|
base.OnFrameworkInitializationCompleted();
|
|
}
|
|
|
|
private void DisableAvaloniaDataAnnotationValidation()
|
|
{
|
|
// Get an array of plugins to remove
|
|
var dataValidationPluginsToRemove =
|
|
BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray();
|
|
|
|
// remove each entry found
|
|
foreach (var plugin in dataValidationPluginsToRemove)
|
|
{
|
|
BindingPlugins.DataValidators.Remove(plugin);
|
|
}
|
|
}
|
|
}
|
|
} |