zoukankan      html  css  js  c++  java
  • 控件模板 1

    简单的使用控件模板

    <Button FontSize="15" HorizontalAlignment="Center" Content="Hello" Width="120" Height="30">
                <Button.Template>
                    <ControlTemplate>
                        <Grid>
                            <Rectangle Fill="Red" RadiusX="15" RadiusY="15"/>
                            <TextBlock Name="textBlock" Margin="{TemplateBinding Button.Padding}" VerticalAlignment="Center"
                                        HorizontalAlignment="Center" Text="{TemplateBinding Button.Content}"/>
                        </Grid>
                    </ControlTemplate>
                </Button.Template>
            </Button>

    使用资源

    <Window.Resources>
            <ControlTemplate x:Key="buttontemplate" TargetType="{x:Type Button}">
                <Border BorderBrush="Orange" BorderThickness="4" CornerRadius="3"
                        Background="Red" TextBlock.Foreground="Black" Margin="30">
                    <ContentPresenter RecognizesAccessKey="True" HorizontalAlignment="Center"
                                       VerticalAlignment="Center"></ContentPresenter>
                </Border>
            </ControlTemplate>
        </Window.Resources>
        <StackPanel>
            <Button FontSize="15" Template="{StaticResource ResourceKey=buttontemplate}" Content="Hello">
            </Button>
        </StackPanel>

  • 相关阅读:
    js字符串使用占位符拼接
    C#解析json字符串总是多出双引号的原因分析及解决办法
    JS 正则验证字符串中是否含有数字
    不错的MVC文章
    Js 更换html同一父元素下子元素的位置
    团队任务个人博客--20160426
    《构建之法》阅读笔记3
    团队任务个人博客20160425
    团队任务个人博客20160424
    软件工程进度条-第八周
  • 原文地址:https://www.cnblogs.com/KimhillZhang/p/2422476.html
Copyright © 2011-2022 走看看