zoukankan      html  css  js  c++  java
  • WPF笔记(1.9 样式和控件模板)——Hello,WPF!

    资源的另一个用途是样式设置:

    <Window >
      
    <Window.Resources>
        
    <Style x:Key="myStyle" TargetType="{x:Type TextBlock}">
          
    <Setter Property="VerticalAlignment" Value="Center" />
          
    <Setter Property="FontWeight" Value="Bold" />
          
    <Setter Property="FontStyle" Value="Italic" />
        
    </Style>
      
    </Window.Resources>
      
    <DockPanel >
        
    <StackPanel >
          
    <TextBlock Style="{StaticResource myStyle}">Name: </TextBlock>
          
    <TextBox Text="{Binding Path=Name}" />
          
    <TextBlock Style="{StaticResource myStyle}">Nick: </TextBlock>
          
    <TextBox Text="{Binding Path=Nick}" />
        
    </StackPanel>
        
      
    </DockPanel>
    </Window>

    代码很容易懂,记住用Setter定义每一个样式,注意指定了x:Key,然后哪个控件需要应用样式,就在控件里面指定Style;如果不指定x:Key,则所有控件都使用这个样式(当然也不会给控件设置Style="{StaticResource myStyle}")。
  • 相关阅读:
    A visual proof that neural nets can compute any function 2
    Matrix
    Formula
    ID and CLASS
    hugeng007_diary01_the living way
    the mathematical knowledge
    sys.argv[]
    The Convolutional Networks
    DVWA之XSS (跨站脚本攻击)存储型+反射型。
    DVWA之 File Inclusion 文件包含
  • 原文地址:https://www.cnblogs.com/Jax/p/695633.html
Copyright © 2011-2022 走看看