--- lang: ja-jp breaks: true --- # WPF `ModernWPF` を試してみる 2022-08-29 > Kinnara/ModernWpf > https://github.com/Kinnara/ModernWpf > ``` > 機能紹介 > WPFの純正コントロールの大半にモダンなスタイルと新機能を搭載。 > > 簡単にカスタマイズできるライトテーマとダークテーマ。ハイコントラストのテーマも含まれています。 > > モダンなアプリケーションを構築するための追加コントロール。Windows UI Libraryから移植されたものもあります。 > > .NET Framework 4.5+、.NET Core 3+、.NET 5+をターゲットにしています。Windows Vista SP2 以上で動作します。 > ``` ## csproj ```xml= <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net7.0-windows</TargetFramework> <Nullable>enable</Nullable> <UseWPF>true</UseWPF> </PropertyGroup> <ItemGroup> <PackageReference Include="ModernWpfUI" Version="0.9.7-preview.2" /> </ItemGroup> </Project> ``` ## App.xaml ```xaml= <Application x:Class="WPF_ModernWPF.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WPF_ModernWPF" StartupUri="MainWindow.xaml" xmlns:ui="http://schemas.modernwpf.com/2019" > <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ui:ThemeResources /> <ui:XamlControlsResources /> <!-- Other merged dictionaries here --> </ResourceDictionary.MergedDictionaries> <!-- Other app resources here --> </ResourceDictionary> </Application.Resources> </Application> ``` ## MainWindows.xaml ```xaml= <Window x:Class="WPF_ModernWPF.MainWindow" 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:local="clr-namespace:WPF_ModernWPF" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800" xmlns:ui="http://schemas.modernwpf.com/2019" ui:WindowHelper.UseModernWindowStyle="True" > <ui:SimpleStackPanel Margin="12" Spacing="24"> <TextBlock Text="My first ModernWPF app" Style="{StaticResource HeaderTextBlockStyle}" /> <Button Content="I am a button" /> <Button Content="I am an accent button" Style="{StaticResource AccentButtonStyle}" /> </ui:SimpleStackPanel> </Window> ``` ## 実行結果   ###### tags: `WPF` `ModernWPF`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up