您好,欢迎来到飒榕旅游知识分享网。
搜索
您的当前位置:首页wpf 引用ttf的方法及使用

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="9.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>

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- sarr.cn 版权所有 赣ICP备2024042794号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务