Browse Source

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.
pull/992/head
Connor Laderer 9 years ago
parent
commit
4ecca2bb53
  1. 18
      src/Avalonia.Controls/AppBuilderBase.cs

18
src/Avalonia.Controls/AppBuilderBase.cs

@ -129,6 +129,24 @@ namespace Avalonia.Controls
Instance.Run(window);
}
/// <summary>
/// Starts the application with the provided instance of <typeparamref name="TMainWindow"/>.
/// </summary>
/// <typeparam name="TMainWindow">The window type.</typeparam>
/// <param name="mainWindow">Instance of type TMainWindow to use when starting the app</param>
/// <param name="dataContextProvider">A delegate that will be called to create a data context for the window (optional).</param>
public void Start<TMainWindow>(TMainWindow mainWindow, Func<object> dataContextProvider = null)
where TMainWindow : Window, new()
{
Setup();
BeforeStartCallback(Self);
if (dataContextProvider != null)
mainWindow.DataContext = dataContextProvider();
mainWindow.Show();
Instance.Run(mainWindow);
}
/// <summary>
/// Sets up the platform-specific services for the application, but does not run it.
/// </summary>

Loading…
Cancel
Save