From 2b2ef3812b78e7290b4d84e6344ccff560108f62 Mon Sep 17 00:00:00 2001 From: SKProCH Date: Wed, 9 Aug 2023 21:43:03 +0300 Subject: [PATCH] Add auto-including Material.DataGrid styles if present --- Material.DataGrid/Material.DataGrid.csproj | 6 ++++++ Material.DataGrid/Material.DataGrid.props | 5 +++++ Material.Demo/App.axaml | 1 - Material.Demo/Material.Demo.csproj | 4 ++++ Material.Styles/MaterialToolKit.xaml.cs | 20 +++++++++++++++----- 5 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 Material.DataGrid/Material.DataGrid.props diff --git a/Material.DataGrid/Material.DataGrid.csproj b/Material.DataGrid/Material.DataGrid.csproj index 1d429e5c..500fa89a 100644 --- a/Material.DataGrid/Material.DataGrid.csproj +++ b/Material.DataGrid/Material.DataGrid.csproj @@ -12,4 +12,10 @@ + + + true + build\;buildTransitive\ + + diff --git a/Material.DataGrid/Material.DataGrid.props b/Material.DataGrid/Material.DataGrid.props new file mode 100644 index 00000000..6d793000 --- /dev/null +++ b/Material.DataGrid/Material.DataGrid.props @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Material.Demo/App.axaml b/Material.Demo/App.axaml index b539d285..8720eb8b 100644 --- a/Material.Demo/App.axaml +++ b/Material.Demo/App.axaml @@ -12,7 +12,6 @@ - diff --git a/Material.Demo/Material.Demo.csproj b/Material.Demo/Material.Demo.csproj index e56aea90..9f216f2e 100644 --- a/Material.Demo/Material.Demo.csproj +++ b/Material.Demo/Material.Demo.csproj @@ -23,6 +23,10 @@ + + + + diff --git a/Material.Styles/MaterialToolKit.xaml.cs b/Material.Styles/MaterialToolKit.xaml.cs index 21f935b1..6b2b5e35 100644 --- a/Material.Styles/MaterialToolKit.xaml.cs +++ b/Material.Styles/MaterialToolKit.xaml.cs @@ -1,16 +1,26 @@ +using System; using Avalonia; using Avalonia.Animation; using Avalonia.Markup.Xaml; +using Avalonia.Markup.Xaml.Styling; using Material.Styles.Additional; -namespace Material.Styles { - public class MaterialToolKit : Avalonia.Styling.Styles { - static MaterialToolKit() { +namespace Material.Styles +{ + public class MaterialToolKit : Avalonia.Styling.Styles + { + static MaterialToolKit() + { Animation.RegisterCustomAnimator(); } - public MaterialToolKit() { + public MaterialToolKit() + { AvaloniaXamlLoader.Load(this); + if (AppContext.TryGetSwitch("MaterialThemeIncludeDataGrid", out var includeDataGrid) && includeDataGrid) + { + Add(new StyleInclude((Uri?)null) { Source = new Uri("avares://Material.DataGrid/DataGrid.xaml") }); + } } } -} +} \ No newline at end of file