FragmentManager 2.0.0
See the version list below for details.
Requires NuGet 4.6.2 or higher.
dotnet add package FragmentManager --version 2.0.0
NuGet\Install-Package FragmentManager -Version 2.0.0
<PackageReference Include="FragmentManager" Version="2.0.0" />
paket add FragmentManager --version 2.0.0
#r "nuget: FragmentManager, 2.0.0"
// Install FragmentManager as a Cake Addin #addin nuget:?package=FragmentManager&version=2.0.0 // Install FragmentManager as a Cake Tool #tool nuget:?package=FragmentManager&version=2.0.0
Пакет предназначен для упрощения работы с wpf приложениями по паттерну MVVM. Приложен простой пример связи View с ViewModel. Заменить в App.xaml Application на fragmentManager c вызовом ConfigurableApplication.
Пример: <fragmentManager:ConfigurableApplication x:Class="Example.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Example" xmlns:fragmentManager="clr-namespace:FragmentManager;assembly=FragmentManager"> <Application.Resources>
</Application.Resources>
</fragmentManager:ConfigurableApplication>
В App.xaml.cs переопределить содержимое. Пример:
public partial class App { private void ConfigureApp() { this.UseDataTemplatesBuilderByAttributes(); this.UseShuriken(); } protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ConfigureApp(); MainWindow = AppContainer.Resolve<MainWindow>(); if (MainWindow != null) { MainWindow.DataContext = AppContainer.Resolve<MainFragmentViewModel>(); MainWindow.Show(); } } protected override void ConfigureContainer(ContainerBuilder builder) { this.ForceLoadAssemblies(); builder.Register(context ⇒ new MainWindow()).SingleInstance(); } }
Каждая ViewModel помечается атрибутом View с типом View: Пример: [View(typeof(TestView))] В свою очередь для вызова фрагмента необходимо вызвать CreateFragment с указанием ключа string. Пример: FragmentService.CreateFragment<TestViewModel>("First"); В XAML указать ContentControl с привязкой данного ключа: Пример: <ContentControl Grid.Column="1" Content="{Binding FragmentService.Fragments[First]}"/>
Библиотека включает в себя Autofac и Shuriken, что позволяет уйти от INotifyPropertyChanged и использовать DependencyInjection в проекте без прямой инициализации Autofac.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.