[源码下载]

背水一战 Windows 10 (45) - 控件(图标类): IconElement, SymbolIcon, FontIcon, PathIcon, BitmapIcon

作者:webabcd

介绍
背水一战 Windows 10 之 控件(图标类)

  • IconElement
  • SymbolIcon
  • FontIcon
  • PathIcon
  • BitmapIcon

示例
1、IconElement(基类) 的示例
Controls/IconControl/IconElementDemo.xaml

<Page
x:Class="Windows10.Controls.IconControl.IconElementDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Controls.IconControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="10 0 10 10"> <!--
SymbolIcon - 符号图标,继承自 IconElement,下面介绍 IconElement 的相关知识点
Foreground - 图标的颜色 注:IconElement 的派生类有: SymbolIcon, FontIcon, PathIcon, BitmapIcon
--> <SymbolIcon Foreground="Red" Symbol="Accept" HorizontalAlignment="Left" Margin="5" /> </StackPanel>
</Grid>
</Page>

Controls/IconControl/IconElementDemo.xaml.cs

/*
* IconElement(基类) - 图标元素基类(继承自 FrameworkElement, 请参见 /Controls/BaseControl/FrameworkElementDemo/)
*/ using Windows.UI.Xaml.Controls; namespace Windows10.Controls.IconControl
{
public sealed partial class IconElementDemo : Page
{
public IconElementDemo()
{
this.InitializeComponent();
}
}
}

2、SymbolIcon 的示例
Controls/IconControl/SymbolIconDemo.xaml

<Page
x:Class="Windows10.Controls.IconControl.SymbolIconDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Controls.IconControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="10 0 10 10"> <!--
SymbolIcon - 符号图标
Symbol - 显示图标的命名常量(枚举值) 注:关于 Symbol 枚举的各种值的显示效果请参见 https://msdn.microsoft.com/zh-cn/library/windows/apps/windows.ui.xaml.controls.symbol.aspx 或者本目录下的“Symbol 枚举.mht”文件
--> <SymbolIcon Symbol="Accept" HorizontalAlignment="Left" Margin="5" /> <SymbolIcon Symbol="Find" HorizontalAlignment="Left" Margin="5" /> <SymbolIcon Symbol="Favorite" HorizontalAlignment="Left" Margin="5" /> </StackPanel>
</Grid>
</Page>

Controls/IconControl/SymbolIconDemo.xaml.cs

/*
* SymbolIcon - 符号图标(继承自 IconElement, 请参见 /Controls/IconControl/IconElementDemo.xaml)
*/ using Windows.UI.Xaml.Controls; namespace Windows10.Controls.IconControl
{
public sealed partial class SymbolIconDemo : Page
{
public SymbolIconDemo()
{
this.InitializeComponent();
}
}
}

3、FontIcon 的示例
Controls/IconControl/FontIconDemo.xaml

<Page
x:Class="Windows10.Controls.IconControl.FontIconDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Controls.IconControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="10 0 10 10"> <!--
FontIcon - 字体图标
FontFamily - 首选字体,多个用“,”分隔,找不到第 1 个就用第 2 个,找不到第 2 个就用第 3 个,以此类推
Glyph - 字符代码
FontSize, FontStyle, FontWeight - 不解释 注:
1、在 xaml 中指定 Glyph 的 Unicode 编码时,不能使用 \u 来指定(code-behind 中可以),而是应该通过 &#x0000; 的方式来指定
2、在“运行”中输入“字符映射表”,打开后可在其中找到不同字体的不同字符的 Unicode 编码
3、除了通过“字符映射表”查找字符的编码外,如果想要查看“Segoe MDL2 Assets”中的各种编码的显示效果请参见 https://docs.microsoft.com/zh-cn/windows/uwp/style/segoe-ui-symbol-font 或者本目录下的“Segoe MDL2 Assets.mht”文件
4、对于 FontIcon 来说,其 FontFamily 的默认值为 Segoe MDL2 Assets
5、支持自定义字体
--> <FontIcon Name="fontIcon1" FontFamily="Segoe UI Emoji" Glyph="✓" HorizontalAlignment="Left" Margin="5" /> <FontIcon Name="fontIcon2" FontFamily="Segoe MDL2 Assets" Glyph="" HorizontalAlignment="Left" Margin="5" /> <!--
在 code-behind 中指定 Glyph
FontIcon 的 FontFamily 的默认值为 Segoe MDL2 Assets
-->
<FontIcon Name="fontIcon3" HorizontalAlignment="Left" Margin="5" /> <!--
演示如何只用自定义字体中的字符(以比较流行的 FontAwesome 为例)
1、将字体文件复制到项目中
2、通过 FontFamily 指定字体文件的路径,在路径后加“#”并在其后写上字体名称(通过“Windows 字体查看器”可以查看字体文件的字体名称)
3、关于 FontAwesome 的各种图标的效果及对应的编码请参见:http://fontawesome.io/cheatsheet/
-->
<FontIcon Name="fontIcon4" FontFamily="/Controls/IconControl/FontAwesome.otf#FontAwesome" Glyph="" HorizontalAlignment="Left" Margin="5" /> <!--
用 TextBlock 或 TextBox 之类的,也是可以显示字体图标的
-->
<TextBlock Name="textBlock" FontFamily="Segoe UI Emoji" Text="✓" HorizontalAlignment="Left" Margin="5" />
<TextBox Name="textBox" FontFamily="/Controls/IconControl/FontAwesome.otf#FontAwesome" Text="" HorizontalAlignment="Left" Margin="5" /> </StackPanel>
</Grid>
</Page>

Controls/IconControl/FontIconDemo.xaml.cs

/*
* FontIcon - 字体图标(继承自 IconElement, 请参见 /Controls/IconControl/IconElementDemo.xaml)
*/ using Windows.UI.Xaml.Controls; namespace Windows10.Controls.IconControl
{
public sealed partial class FontIconDemo : Page
{
public FontIconDemo()
{
this.InitializeComponent(); this.Loaded += FontIconDemo_Loaded;
} private void FontIconDemo_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
// 在 code-behind 中可以通过 \u 指定 Unicode 编码
fontIcon3.Glyph = "\uEC52";
}
}
}

4、PathIcon 的示例
Controls/IconControl/PathIconDemo.xaml

<Page
x:Class="Windows10.Controls.IconControl.PathIconDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Controls.IconControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="10 0 10 10"> <!--
PathIcon - 路径图标
Data - 路径的 Geometry 数据(关于 Geometry 请参见:/Drawing/Path.xaml)
--> <PathIcon Margin="5">
<PathIcon.Data>
<EllipseGeometry Center="50,25" RadiusX="50" RadiusY="25" />
</PathIcon.Data>
</PathIcon> <PathIcon Margin="5" Data="F1 M 20,20L 24,10L 24,24L 5,24" /> </StackPanel>
</Grid>
</Page>

Controls/IconControl/PathIconDemo.xaml.cs

/*
* PathIcon - 路径图标(继承自 IconElement, 请参见 /Controls/IconControl/IconElementDemo.xaml)
*/ using Windows.UI.Xaml.Controls; namespace Windows10.Controls.IconControl
{
public sealed partial class PathIconDemo : Page
{
public PathIconDemo()
{
this.InitializeComponent();
}
}
}

5、BitmapIcon 的示例
Controls/IconControl/BitmapIconDemo.xaml

<Page
x:Class="Windows10.Controls.IconControl.BitmapIconDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.Controls.IconControl"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <Grid Background="Transparent">
<StackPanel Margin="10 0 10 10"> <!--
BitmapIcon - 位图图标
UriSource - 图片地址
--> <BitmapIcon UriSource="/Assets/StoreLogo.png" HorizontalAlignment="Left" Width="40" Height="40" Margin="5" /> </StackPanel>
</Grid>
</Page>

Controls/IconControl/BitmapIconDemo.xaml.cs

/*
* BitmapIcon - 位图图标(继承自 IconElement, 请参见 /Controls/IconControl/IconElementDemo.xaml)
*/ using Windows.UI.Xaml.Controls; namespace Windows10.Controls.IconControl
{
public sealed partial class BitmapIconDemo : Page
{
public BitmapIconDemo()
{
this.InitializeComponent();
}
}
}

OK
[源码下载]

背水一战 Windows 10 (45) - 控件(图标类): IconElement, SymbolIcon, FontIcon, PathIcon, BitmapIcon的更多相关文章

  1. 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButton, AppBarButton, AppBarToggleButton

    [源码下载] 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButt ...

  2. 背水一战 Windows 10 (30) - 控件(文本类): AutoSuggestBox

    [源码下载] 背水一战 Windows 10 (30) - 控件(文本类): AutoSuggestBox 作者:webabcd 介绍背水一战 Windows 10 之 控件(文本类) AutoSug ...

  3. 背水一战 Windows 10 (74) - 控件(控件基类): UIElement - 与 CanDrag 相关的事件, 与 AllowDrop 相关的事件

    [源码下载] 背水一战 Windows 10 (74) - 控件(控件基类): UIElement - 与 CanDrag 相关的事件, 与 AllowDrop 相关的事件 作者:webabcd 介绍 ...

  4. 背水一战 Windows 10 (40) - 控件(导航类): AppBar, CommandBar

    [源码下载] 背水一战 Windows 10 (40) - 控件(导航类): AppBar, CommandBar 作者:webabcd 介绍背水一战 Windows 10 之 控件(导航类) App ...

  5. 背水一战 Windows 10 (44) - 控件(日期类): CalendarView, DatePicker, TimePicker

    [源码下载] 背水一战 Windows 10 (44) - 控件(日期类): CalendarView, DatePicker, TimePicker 作者:webabcd 介绍背水一战 Window ...

  6. 背水一战 Windows 10 (37) - 控件(弹出类): MessageDialog, ContentDialog

    [源码下载] 背水一战 Windows 10 (37) - 控件(弹出类): MessageDialog, ContentDialog 作者:webabcd 介绍背水一战 Windows 10 之 控 ...

  7. 背水一战 Windows 10 (36) - 控件(弹出类): ToolTip, Popup, PopupMenu

    [源码下载] 背水一战 Windows 10 (36) - 控件(弹出类): ToolTip, Popup, PopupMenu 作者:webabcd 介绍背水一战 Windows 10 之 控件(弹 ...

  8. 背水一战 Windows 10 (35) - 控件(弹出类): FlyoutBase, Flyout, MenuFlyout

    [源码下载] 背水一战 Windows 10 (35) - 控件(弹出类): FlyoutBase, Flyout, MenuFlyout 作者:webabcd 介绍背水一战 Windows 10 之 ...

  9. 背水一战 Windows 10 (34) - 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing

    [源码下载] 背水一战 Windows 10 (34) - 控件(进度类): RangeBase, Slider, ProgressBar, ProgressRing 作者:webabcd 介绍背水一 ...

随机推荐

  1. R.java的生成规则

    0x7f010000 开头的是attr 0x7f050000 开头的是anim 0x7f0b0002 开头的是bool 0x7f020000 开头的是drawable 0x7f060000 开头的是i ...

  2. 第五周 PSP 燃尽图 以及 进度条总结

    1.PSP DATE START-TIME END-TIME EVENT           DELTA TYPE 3.12 9.30 11.30 环境搭建 音乐30min QQ25min       ...

  3. oracle merge into语法

    oracle的merge into语法,在这种情况下: 基于某些字段,存在就更新,不存在就插入 不需要先去判断一下记录是否存在,直接使用merge into oerge into 语法: MERGE ...

  4. mac os下 android studio真机调试

    http://www.cnblogs.com/developer-wang/p/6719555.html 如果没有 .bash_profile 只需要创建 .bash_profile,然后增加andr ...

  5. springboot aop+@interface实现日志记录

    一.基本概念 1.自定义注解 自定义注解我们必须了解四个元注解,什么是元注解?元注解指作用于注解之上的元数据或者元信息,简单通俗的讲,元注解就是注解的注解 . Documented与Inherited ...

  6. python.csv 按行按列读取

    参考:https://blog.csdn.net/ly_ysys629/article/details/55107237 # header=0,表示文件第0行为列索引 # index_col=0,表示 ...

  7. keras model.compile(loss='目标函数 ', optimizer='adam', metrics=['accuracy'])

    深度学习笔记 目标函数的总结与整理   目标函数,或称损失函数,是网络中的性能函数,也是编译一个模型必须的两个参数之一.由于损失函数种类众多,下面以keras官网手册的为例. 在官方keras.io里 ...

  8. Java四种排序:冒泡,选择,插入,二分(折半插入)

    四种排序:冒泡,选择,插入,二分(折半插入) public class Test{ // public static void main(String[] args) { // Test t=new ...

  9. tabindex属性用法

    支持tabindex属性的元素:<a> <input> <textarea> <area> <select> <button> ...

  10. HTML上传文件支持大文件上传,下载

    上传 1.修改配置文件web.config,在<system.webServer>下面加入 <security> <requestFiltering > <r ...