PowerShell | Install-Package IdeaBlade.Cocktail -ProjectName HelloWorld.Wpf |
PowerShell | Install-Package IdeaBlade.DevForce.Server -ProjectName HelloWorld.Wpf |
C# | using System.ComponentModel.Composition; using System.Threading.Tasks; using Cocktail; namespace HelloWorld.Wpf { [Export] public class MainViewModel { private readonly IDialogManager _dialogManager; [ImportingConstructor] public MainViewModel(IDialogManager dialogManager) { _dialogManager = dialogManager; } public async Task SayHello() { await _dialogManager.ShowMessageAsync("Hello World!", DialogButtons.Ok); } } } |
XAML | <Window x:Class="HelloWorld.Wpf.MainView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> <Grid> <Button Content="Say Hello" x:Name="SayHello" /> </Grid> </Window> |
C# | using Cocktail; namespace HelloWorld.Wpf { public class AppBootstrapper : CocktailMefBootstrapper<MainViewModel> { } } |
XAML | <Application x:Class="HelloWorld.Wpf.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:HelloWorld.Wpf"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary> <local:AppBootstrapper x:Key="bootstrapper" /> </ResourceDictionary> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application> |