wpf 引用ttf的方法及使用

<Application x:Class="WpfApp05.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:WpfApp05"
             StartupUri="TestWindow.xaml">
    <Application.Resources>
        <FontFamily x:Key="iconfont">Resources/#iconfont</FontFamily>
    </Application.Resources>
</Application>
<Window x:Class="WpfApp05.TestWindow"
        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:WpfApp05"
        mc:Ignorable="d"
        FontFamily="Microsoft YaHei" FontWeight="ExtraLight" Foreground="#333"
        WindowStyle="None" AllowsTransparency="True"  WindowStartupLocation="CenterScreen" Background="#FFF6F7FC"
        ResizeMode="CanResizeWithGrip"
        Title="TestWindow" Height="549.057" Width="815.094" MouseLeftButtonDown="Win_MouseLeftButtonDown">
    <Window.Resources>
        <Style TargetType="RadioButton" x:Key="LeftMenuItemButtonStyle">
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontSize" Value="24"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="RadioButton">
                        <Grid Background="Transparent" Height="50" Name="back">
                            <TextBlock Text="{TemplateBinding Content}" FontFamily="{StaticResource iconfont}"
                                       VerticalAlignment="Center" HorizontalAlignment="Center"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="#11FFFFFF" TargetName="back"/>
                            </Trigger>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter Property="Background" Value="#33FFFFFF" TargetName="back"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="60"></ColumnDefinition>
            <ColumnDefinition></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Border Background="#FF0B0BAA">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                    <RowDefinition></RowDefinition>
                </Grid.RowDefinitions>

                <StackPanel Grid.Row="1" VerticalAlignment="Center">
                    <RadioButton Content="&#xe68b;"  IsChecked="True" Style="{StaticResource LeftMenuItemButtonStyle}"
                                 ToolTip="Dashboard"
                                 Command="{Binding MenuItemCommand}"
                                 CommandParameter="MonitorView"/>
                    <RadioButton Content="&#xe630;"  Style="{StaticResource LeftMenuItemButtonStyle}"
                                 ToolTip="设备"
                                 Command="{Binding MenuItemCommand}"
                                 CommandParameter="DeviceView" />
                    <RadioButton Content="&#xe6ba;"  Style="{StaticResource LeftMenuItemButtonStyle}"
                                 ToolTip="报警"
                                 Command="{Binding MenuItemCommand}"
                                 CommandParameter="AlarmView" />
                    <RadioButton Content="&#xe655;"  Style="{StaticResource LeftMenuItemButtonStyle}"
                                 ToolTip="报表"
                                 Command="{Binding MenuItemCommand}"
                                 CommandParameter="ReportView" Cursor="Hand"/>
                </StackPanel>
            </Grid>
        </Border>
    </Grid>
</Window>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值