Skip to content

Commit

Permalink
Add auto-including Material.DataGrid styles if present
Browse files Browse the repository at this point in the history
  • Loading branch information
SKProCH committed Aug 9, 2023
1 parent 0b4c1dd commit 2b2ef38
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
6 changes: 6 additions & 0 deletions Material.DataGrid/Material.DataGrid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
<ProjectReference Include="..\Material.Styles\Material.Styles.csproj"/>
</ItemGroup>

<ItemGroup>
<Content Include="*.props">
<Pack>true</Pack>
<PackagePath>build\;buildTransitive\</PackagePath>
</Content>
</ItemGroup>
</Project>
5 changes: 5 additions & 0 deletions Material.DataGrid/Material.DataGrid.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<RuntimeHostConfigurationOption Include="MaterialThemeIncludeDataGrid" Value="true" />
</PropertyGroup>
</Project>
1 change: 0 additions & 1 deletion Material.Demo/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<themes:MaterialTheme PrimaryColor="Purple" SecondaryColor="Indigo" />

<avalonia:MaterialIconStyles />
<StyleInclude Source="avares://Material.DataGrid/DataGrid.xaml" />
<dialogHostAvalonia:DialogHostStyles />

<!-- AvaloniaEdit styles -->
Expand Down
4 changes: 4 additions & 0 deletions Material.Demo/Material.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<ProjectReference Include="..\Material.DataGrid\Material.DataGrid.csproj"/>
<ProjectReference Include="..\Material.Dialog\Material.Dialog.csproj"/>
</ItemGroup>

<ItemGroup>
<RuntimeHostConfigurationOption Include="MaterialThemeIncludeDataGrid" Value="true" />
</ItemGroup>

<ItemGroup>
<AvaloniaResource Include="Assets\**"/>
Expand Down
20 changes: 15 additions & 5 deletions Material.Styles/MaterialToolKit.xaml.cs
Original file line number Diff line number Diff line change
@@ -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<RelativePoint, RelativePointAnimator>();
}

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") });
}
}
}
}
}

0 comments on commit 2b2ef38

Please sign in to comment.