• WPF-样式


    <Window x:Class="Wpf.Window2"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:sys="clr-namespace:System;assembly=mscorlib"
            Title="Window2" Height="300" Width="300">
        <Window.Resources>
            <FontFamily x:Key="a1">Times New Roman</FontFamily>
            <sys:Double x:Key="a2">18</sys:Double>
            <FontWeight x:Key="a3">Bold</FontWeight>
            
            <Style x:Key="Big">
    <Style.Triggers>
                    <Trigger Property="Control.IsFocused" Value="true">
                        <Setter  Property="Control.Background" >
                            <Setter.Value>
                                <LinearGradientBrush>
                                    <GradientStop Color="Chocolate" Offset="0.3"></GradientStop>
                                    <GradientStop Color="White"></GradientStop>
                                </LinearGradientBrush>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
    
    
                <Setter Property="Control.FontSize" Value="35"></Setter>
                <Setter Property="Control.Background" >
                    <Setter.Value>
                        <LinearGradientBrush  StartPoint="0,0" EndPoint="1,1" >
                            <GradientStop Color="Beige" Offset="0.5"></GradientStop>
                            <GradientStop Color="HotPink"></GradientStop>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Style>
        </Window.Resources>
        <Grid>
            <StackPanel>
                <TextBox FontFamily="{StaticResource ResourceKey=a1}" FontWeight="{StaticResource ResourceKey=a3}" FontSize="{StaticResource ResourceKey=a2}"></TextBox>
                <TextBox  Style="{StaticResource ResourceKey=Big}"></TextBox>
                <TextBox x:Name="txt1"></TextBox>
            </StackPanel>
        </Grid>
    </Window>

    也可在后台代码输入—

    txt1.Style = (Style)this.FindResource("Big");

    以上为简单的样式行为,样式可分为:关联事件样式-多层样式-通过类型自动应用样式-触发器样式

    简单动画:实现文本框的文字放大缩小

    <Window x:Class="Wpf.Window3"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="Window3" Height="300" Width="300">
        <Window.Resources>
            <Style  x:Key="big" TargetType="TextBox">
                <Style.Triggers>
                    <EventTrigger RoutedEvent="TextBox.MouseEnter">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:0.3" Storyboard.TargetProperty="FontSize" To="50"></DoubleAnimation>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                    <EventTrigger RoutedEvent="TextBox.MouseLeave">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation Duration="0:0:0.1" Storyboard.TargetProperty="FontSize" ></DoubleAnimation>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Style.Triggers>
            </Style>
        </Window.Resources>
    
            <StackPanel>
            <TextBox   Style="{StaticResource big}" Height="100">3333312222222222222222222222222222222222222222222222222222221</TextBox>
        </StackPanel>
    
    </Window>
    三思而又行。
  • 相关阅读:
    Spark Shuffle FetchFailedException解决方案
    Spark常见问题汇总
    网络表示学习介绍
    Graph Embedding: metapath2vec算法
    spark参数介绍
    spark文章
    集群运行Spark程序实例讲解
    基于Spark UI性能优化与调试——初级篇
    Spark Shuffle FetchFailedException
    没有指针的java语言
  • 原文地址:https://www.cnblogs.com/jun-jie/p/3728071.html
Copyright © 2020-2023  润新知