FragmentManager 2.0.0

There is a newer version of this package available.
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                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FragmentManager" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FragmentManager --version 2.0.0                
#r "nuget: FragmentManager, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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.

GitHub: https://github.com/okrug102m/FragmentManager

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
3.0.0 399 1/1/2022
2.1.0 574 5/22/2020
2.0.0 476 5/22/2020
1.0.0 680 2/19/2020 1.0.0 is deprecated because it is no longer maintained.