From 4ecca2bb53fa4107ae1611d1a874eee14dc20145 Mon Sep 17 00:00:00 2001 From: Connor Laderer Date: Wed, 24 May 2017 22:08:33 -0400 Subject: [PATCH 1/3] Added overload of Start for AppBuilderBase This will allow for easy use of Dependency Injection with Microsoft.Extensions.DependencyInjection the mainWindow can resolve any constructor objects it may have. --- src/Avalonia.Controls/AppBuilderBase.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Avalonia.Controls/AppBuilderBase.cs b/src/Avalonia.Controls/AppBuilderBase.cs index 97de093a59..13e9c108e1 100644 --- a/src/Avalonia.Controls/AppBuilderBase.cs +++ b/src/Avalonia.Controls/AppBuilderBase.cs @@ -129,6 +129,24 @@ namespace Avalonia.Controls Instance.Run(window); } + /// + /// Starts the application with the provided instance of . + /// + /// The window type. + /// Instance of type TMainWindow to use when starting the app + /// A delegate that will be called to create a data context for the window (optional). + public void Start(TMainWindow mainWindow, Func dataContextProvider = null) + where TMainWindow : Window, new() + { + Setup(); + BeforeStartCallback(Self); + + if (dataContextProvider != null) + mainWindow.DataContext = dataContextProvider(); + mainWindow.Show(); + Instance.Run(mainWindow); + } + /// /// Sets up the platform-specific services for the application, but does not run it. /// From 0a65816ae1fe37dcbe585469235f98449b1f2d25 Mon Sep 17 00:00:00 2001 From: Connor Laderer Date: Wed, 24 May 2017 22:19:14 -0400 Subject: [PATCH 2/3] Corrected where statement because if its provided, it doesn't need a parameterless constructor --- src/Avalonia.Controls/AppBuilderBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/AppBuilderBase.cs b/src/Avalonia.Controls/AppBuilderBase.cs index 13e9c108e1..30ef7dc427 100644 --- a/src/Avalonia.Controls/AppBuilderBase.cs +++ b/src/Avalonia.Controls/AppBuilderBase.cs @@ -136,7 +136,7 @@ namespace Avalonia.Controls /// Instance of type TMainWindow to use when starting the app /// A delegate that will be called to create a data context for the window (optional). public void Start(TMainWindow mainWindow, Func dataContextProvider = null) - where TMainWindow : Window, new() + where TMainWindow : Window { Setup(); BeforeStartCallback(Self); From 4fa6c1e7f4f89a6f975427ef0ebcb15da35b5789 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Fri, 26 May 2017 00:53:37 +0200 Subject: [PATCH 3/3] Fixed invalid doc references. --- src/Avalonia.Controls/AppBuilderBase.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Controls/AppBuilderBase.cs b/src/Avalonia.Controls/AppBuilderBase.cs index 30ef7dc427..1610d33f9b 100644 --- a/src/Avalonia.Controls/AppBuilderBase.cs +++ b/src/Avalonia.Controls/AppBuilderBase.cs @@ -55,8 +55,7 @@ namespace Avalonia.Controls public Action AfterSetupCallback { get; private set; } = builder => { }; /// - /// Gets or sets a method to call before is called on the - /// . + /// Gets or sets a method to call before Startis called on the . /// public Action BeforeStartCallback { get; private set; } = builder => { }; @@ -94,8 +93,7 @@ namespace Avalonia.Controls protected TAppBuilder Self => (TAppBuilder) this; /// - /// Registers a callback to call before is called on the - /// . + /// Registers a callback to call before Start is called on the . /// /// The callback. /// An instance.