よく使う初期環境 MaterialDesignThemes 3.1.3 対応版
よく使う初期環境 のMaterialDesignThemes 3.1.3 対応版
- ControlzEx 4.3.2
- LivetCask 3.2.3.1
- LivetCask.Behaviors 3.2.3.1
- LivetCask.Collections 3.2.3.1
- LivetCask.Converters 3.2.3.1
- LivetCask.Core 3.2.3.1
- LivetCask.EventListeners 3.2.3.1
- LivetCask.Messaging 3.2.3.1
- LivetCask.Mvvm 3.2.3.1
- MahApps.Metro 2.2.0
- MaterialDesignColors 1.2.6
- MaterialDesignThemes 3.1.3
- MaterialDesignThemes.MahApps 0.1.4
- Microsoft.Xaml.Behaviors.Wpf 1.1.19
App.xaml
<Application x:Class="WpfApp1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApp1"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
StartupUri="View\MainView.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--MahApps-->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Steel.xaml" />
<!--Material Design-->
<materialDesign:BundledTheme BaseTheme="Light" PrimaryColor="Indigo" SecondaryColor="Indigo" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<!--Material Design: MahApps統合設定 -->
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Flyout.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
View\MainView.xaml
<metro:MetroWindow
x:Class="WpfApp1.View.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:l="http://schemas.livet-mvvm.net/2011/wpf"
xmlns:local="clr-namespace:WpfApp1"
xmlns:vm="clr-namespace:WpfApp1.ViewModel"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
mc:Ignorable="d"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
ResizeMode="CanResizeWithGrip"
WindowStartupLocation="CenterScreen"
BorderThickness="1"
GlowBrush="{DynamicResource MahApps.Brushes.Accent}"
WindowTransitionsEnabled="False"
TitleCharacterCasing="Normal"
ShowIconOnTitleBar="True"
Title="MainView" Height="450" Width="800">
<Window.DataContext>
<vm:MainViewModel>
<vm:MainViewModel.MahAppsDialogCoordinator>
<Dialog:DialogCoordinator/>
</vm:MainViewModel.MahAppsDialogCoordinator>
</vm:MainViewModel>
</Window.DataContext>
<i:Interaction.Triggers>
<i:EventTrigger EventName ="ContentRendered">
<l:LivetCallMethodAction MethodTarget="{Binding}" MethodName="OnContentRendered" />
</i:EventTrigger>
<l:InteractionMessageTrigger Messenger="{Binding Messenger}" MessageKey="Information">
<l:InformationDialogInteractionMessageAction InvokeActionOnlyWhenWindowIsActive="False" />
</l:InteractionMessageTrigger>
</i:Interaction.Triggers>
<Grid>
<Button Content="Test">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<l:LivetCallMethodAction MethodTarget="{Binding}" MethodName="OnButtonClicked" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</metro:MetroWindow>
View\MainView.xaml.cs
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
namespace WpfApp1.View
{
/// <summary>
/// MainView.xaml の相互作用ロジック
/// </summary>
public partial class MainView : MetroWindow
{
public MainView()
{
InitializeComponent();
this.Loaded += (sender, args) =>
{
DialogParticipation.SetRegister(this, this.DataContext);
};
this.Unloaded += (sender, args) =>
{
DialogParticipation.SetRegister(this, null);
};
}
}
}
ViewModel\MainViewModel.cs
using MahApps.Metro.Controls.Dialogs;
namespace WpfApp1.ViewModel
{
public class MainViewModel : Livet.ViewModel
{
public IDialogCoordinator MahAppsDialogCoordinator { get; set; }
public void OnContentRendered()
{
}
public async void OnButtonClicked()
{
await MahAppsDialogCoordinator.ShowMessageAsync(this, "ShowMessageBox", "ShowMessageBoxText");
}
}
}
ディスカッション
コメント一覧
まだ、コメントがありません