MahApps.Metro.IconPacks を使ってみる

「MahApps.Metro.IconPacks」について記載します。

 

 

 

1. まずは使ってみる

[概要] MahApps.Metro.IconPacks をとりあえず使ってみます。

 

[評価環境]

コンパイラ : Visual Studio 2019 pro., Version 16.4.5
OS: Windows10 home, Version 1909
Parts: MahApps.Metro.IconPacks, v3.2.0

 

(1) WPF の新規プロジェクトを作成します。

WPF の新規プロジェクトを作成

 

(2) 「NuGet パッケージマネージャ」 で "MahApps.Metro.IconPack" をインストールします。

「NuGet パッケージマネージャ」 で MahApps.Metro.IconPack をインストール

変更のプレビュー

 

(3) 以下のようにコードを書いて、[F5]実行します。ここでは "Logos_500px" というアイコンを表示します。

[MainWindow.xaml]

<Window x:Class="test_01.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:test_01"
        
        xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
        
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <iconPacks:PackIconBoxIcons Kind="Logos_500px" />      
    </Grid>
</Window>

 

すると、こんな感じで動作しました。

動作例

 

(4) あとはアイコンの位置と大きさ、ウィンドウの大きさ、などを調整します。

調整後の結果は以下の通り。これでいったん完成です。

アイコンの位置と大きさ、ウィンドウの大きさ などを調整後の動作例

 

[MainWindow.xaml]

<Window x:Class="test_01.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:test_01"
        
        xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
        
        mc:Ignorable="d"
        Title="MainWindow" Height="300" Width="400">
    <Grid>
        <iconPacks:PackIconBoxIcons Kind="Logos_500px" Margin="100,100,0,0" Width="48" Height="48" />  
    </Grid>
</Window>

 

参考

 

 

2. IconPacks-Browser で使いたいアイコンを選ぶ

[概要]

IconPacks はとても多くのアイコンを持っています。"IconPacks-Browser" で使いたいアイコンを探して、自分が作成するアプリケーションで使えるようにしましょう。

 

[評価環境]

コンパイラ : Visual Studio 2019 pro., Version 16.4.5
OS: Windows10 home, Version 1909
Parts: MahApps.Metro.IconPacks, v3.2.0

 

 

この辺(↓)から IconPacks-Browser を入手します。
IconPacks-Browser
https://github.com/MahApps/MahApps.Metro.IconPacks/wiki/IconPacks-Browser
https://github.com/MahApps/MahApps.Metro.IconPacks/releases/latest
https://github.com/MahApps/MahApps.Metro.IconPacks/releases/download/3.2.0/IconPacks.Browser.Release-v3.2.0-rc0007.zip

 

実行したときの画面様子は下図の通り。

IconPacks-Browser 動作例

 

「Copy *** to clipboard as element」 ボタンをクリックすると、

「Copy *** to clipboard as element」 ボタンをクリックした様子

 

<iconPacks:PackIconOcticons Kind="Bug" />

というようなコードがクリップボードにコピーされます。
前の章で記載した例は、この形式です。

 

「Copy *** to clipboard as content」 ボタンをクリックすると、

「Copy *** to clipboard as content」 ボタンをクリックした様子

{iconPacks:Octicons Kind=Bug}

というようなコードがクリップボードにコピーされます。

 

「Copy *** to clipboard as PathIcon element」 ボタンをクリックすると、

「Copy *** to clipboard as PathIcon element」 ボタンをクリックした様子

<iconPacks:PathIconOcticons Kind="Bug" />

というようなコードがクリップボードにコピーされます。

 

以上のような方法でこの IconPacks-Browser を使うことで、使いたいアイコンを上記のようにクリップボード経由で張り付けるだけで楽に自身のアプリケーションでアイコンを活用することができます。

 

 

ライセンス

本ページの情報は、特記無い限り下記 MIT ライセンスで提供されます。

The MIT License (MIT)

Copyright © 2022 Kinoshita Hidetoshi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 

 

 

参考

 


 

変更履歴

2022-07-18 - デザイン更新
2020-03-01 - 新規作成

 

Programming Items トップページ

プライバシーポリシー