zoukankan      html  css  js  c++  java
  • WPF学习记录 三、控件模版

    可以给控件增加模版样式

    如下就把一个按钮,完成变成了其它的样式:

        <Window.Resources>
            <ControlTemplate  x:Key="myTemplate" TargetType="Button">
                <Border Background="Red" CornerRadius="5">
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
                        <TextBlock Text="$" VerticalAlignment="Center"></TextBlock>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}"></ContentPresenter>
                    </StackPanel>
                </Border>
            </ControlTemplate>
        </Window.Resources>
        <Grid>
            <DockPanel  LastChildFill="False">
                <Button DockPanel.Dock="Left" Height="50" Width="100" Template="{StaticResource myTemplate}" HorizontalAlignment="Center" VerticalAlignment="Center"  Content="确定"></Button>
            </DockPanel>
        </Grid>

  • 相关阅读:
    volatile用法
    static用法
    sizeof用法
    C语言void关键字的深刻含义
    extern用法
    const用法
    attribute用法
    Task的运行过程分析
    Android BroadcastReceiver实例Demo(有序广播的发送)
    旅行-许巍
  • 原文地址:https://www.cnblogs.com/wjx-blog/p/15423550.html
Copyright © 2011-2022 走看看