ソースを参照

Make sure DataGrid is loaded in designer.

Add an `AppBuilder` extension instead of calling `DataGrid.Load` so that the `Avalonia.Controls.DataGrid` assembly gets loaded in the designer.
Steven Kirk 6 年 前
コミット
561f070615

+ 5 - 3
samples/ControlCatalog.Desktop/Program.cs

@@ -13,8 +13,6 @@ namespace ControlCatalog
         [STAThread]
         static void Main(string[] args)
         {
-            Avalonia.Controls.DataGrid.Load();
-            
             // TODO: Make this work with GTK/Skia/Cairo depending on command-line args
             // again.
             BuildAvaloniaApp().Start<MainWindow>();
@@ -24,7 +22,11 @@ namespace ControlCatalog
         /// This method is needed for IDE previewer infrastructure
         /// </summary>
         public static AppBuilder BuildAvaloniaApp()
-            => AppBuilder.Configure<App>().LogToDebug().UsePlatformDetect().UseReactiveUI();
+            => AppBuilder.Configure<App>()
+                .LogToDebug()
+                .UsePlatformDetect()
+                .UseReactiveUI()
+                .UseDataGrid();
 
         private static void ConfigureAssetAssembly(AppBuilder builder)
         {

+ 5 - 2
samples/ControlCatalog.NetCore/Program.cs

@@ -12,7 +12,6 @@ namespace ControlCatalog.NetCore
 
         static void Main(string[] args)
         {
-            Avalonia.Controls.DataGrid.Load();
             Thread.CurrentThread.TrySetApartmentState(ApartmentState.STA);
             if (args.Contains("--wait-for-attach"))
             {
@@ -44,7 +43,11 @@ namespace ControlCatalog.NetCore
         /// This method is needed for IDE previewer infrastructure
         /// </summary>
         public static AppBuilder BuildAvaloniaApp()
-            => AppBuilder.Configure<App>().UsePlatformDetect().UseSkia().UseReactiveUI();
+            => AppBuilder.Configure<App>()
+                .UsePlatformDetect()
+                .UseSkia()
+                .UseReactiveUI()
+                .UseDataGrid();
 
         static void ConsoleSilencer()
         {

+ 20 - 0
src/Avalonia.Controls.DataGrid/AppBuilderExtensions.cs

@@ -0,0 +1,20 @@
+// Copyright (c) The Avalonia Project. All rights reserved.
+// Licensed under the MIT license. See licence.md file in the project root for full license information.
+
+using Avalonia.Controls;
+using Avalonia.Threading;
+
+namespace Avalonia
+{
+    public static class AppBuilderExtensions
+    {
+        public static TAppBuilder UseDataGrid<TAppBuilder>(this TAppBuilder builder)
+            where TAppBuilder : AppBuilderBase<TAppBuilder>, new()
+        {
+            // Portable.Xaml doesn't correctly load referenced assemblies and so doesn't
+            // find `DataGrid` when loading XAML. Call this method from AppBuilder as a
+            // temporary workaround until we fix XAML.
+            return builder;
+        }
+    }
+}

+ 1 - 9
src/Avalonia.Controls.DataGrid/DataGrid.cs

@@ -5949,13 +5949,5 @@ namespace Avalonia.Controls
         {
             AutoGeneratingColumn?.Invoke(this, e);
         }
-
-        /// <summary>
-        /// Loads this assembly in runtime.
-        /// </summary>
-        public static void Load()
-        {
-
-        }
     }
-}
+}