首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏dino.c的专栏

    理解ControlTemplate中的VisualTransition

    为什么有时候VisualTransition没有生效 ControlTemplate在VisualState之间切换是靠下面这个函数控制的: // // 摘要: // 通过按名称请求新的 Windows.UI.Xaml.VisualState

    86830发布于 2019-01-18
  • 来自专栏dino.c的专栏

    如何使用代码创建DataTemplate(或者ControlTemplate)

    </StackPanel> </DataTemplate> </controls:DataGridTemplateColumn.CellTemplate> 而且DateTemplate(或ControlTemplate 对于XamlReader,我平时用得最多的就是用来创建DataTemplate和ControlTemplate这些不方便用代码构建的元素。

    2.4K20发布于 2019-01-16
  • 来自专栏dino.c的专栏

    如何使用代码创建DataTemplate(或者ControlTemplate)

    前言 上一篇文章([UWP]如何使用代码创建DataTemplate(或者ControlTemplate))介绍了在UWP上的情况,这篇文章再稍微介绍在WPF上如何实现。 2.

    2.4K80发布于 2019-01-18
  • 来自专栏dino.c的专栏

    如何使用代码创建DataTemplate(或者ControlTemplate)

    前言 上一篇文章([UWP]如何使用代码创建DataTemplate(或者ControlTemplate))介绍了在UWP上的情况,这篇文章再稍微介绍在WPF上如何实现。 2.

    2.5K20发布于 2019-01-17
  • 来自专栏dino.c的专栏

    如何使用代码创建DataTemplate(或者ControlTemplate)

    </StackPanel> </DataTemplate> </controls:DataGridTemplateColumn.CellTemplate> 而且DateTemplate(或ControlTemplate 对于XamlReader,我平时用得最多的就是用来创建DataTemplate和ControlTemplate这些不方便用代码构建的元素。

    1.6K30发布于 2019-01-18
  • 来自专栏dino.c的专栏

    自定义控件的代码如何与ControlTemplate交互

    正确的做法应该是使用代码告诉ControlTemplate去改变外观,或者控制ControlTemplate中可用的元素进入某个状态。 > </ControlTemplate> 可以为ControlTemplate添加Triggers,内容为Trigger或EventTrigger的集合,Triggers通过响应属性值变更或事件更改控件的外观 控件逻辑预期这些部分存在于ControlTemplate中,控件在加载ControlTemplate后会调用OnApplyTemplate,可以在这个函数中调用protected DependencyObject TemplatePartAttribute协定 有时,为了表明控件期待在ControlTemplate存在某个特定部件,防止编辑ControlTemplate的开发人员删除它,控件上会添加添加TemplatePartAttribute 即使不自定义控件,学会使用ControlTemplate也是一件好事,下面给出一些有用的参考链接。 9.

    2.7K20发布于 2019-05-23
  • 来自专栏dino.c的专栏

    为什么ContentControl的ControlTemplate里放两个ContentPresenter会出问题(绕口)

    简单的HeaderedContentControl 上周五收到反馈,在一个ContentControl的ControlTemplate中放两个ContentPresenter会出错。 ; } protected virtual void OnHeaderChanged(object oldValue, object newValue) { } } ControlTemplate 如下: <ControlTemplate TargetType="local:HeaderedContentControl"> <Border Background="{TemplateBinding 问题产生的原因及解决方案 第一种错误,看起来是ContentControl将Content赋值给<em>ControlTemplate</em>的所有ContentPresenter了。 虽然没看过ContentControl的源码,但我了解到如果ContentPresenter在ContentControl的<em>ControlTemplate</em>中,当ContentPresenter的Content

    78730发布于 2019-03-08
  • 来自专栏dino.c的专栏

    [UWP 自定义控件]了解模板化控件(1):基础知识

    通过为控件赋予新的ControlTemplate,可以为控件创建全新的外观。在下面的例子中,通过ControlTemplate将Button改成一个圆形按钮。 ControlTemplate的内容是定义控件可视结构的XAML。 将ControlTemplate赋值到Control.Template即可改变控件的外观。ControlTemplate的TargetType需要和使用它的控件匹配。 注意:UserControl不能使用ControlTemplate。 ,例如Button、ComboBox等,它们中的大部分都有默认的ControlTemplate

    94530发布于 2019-01-18
  • 来自专栏小狼的世界

    Silverlight学习笔记:改变控件的样式

    这就是通过 ControlTemplate 来改变控件的外观。   Cotrol Template 的设置有三种方式:     将 Template 本地设置成内联定义的 ControlTemplate;     将 Template 本地设置成对定义资源的 ControlTemplate --Define the ControlTemplate here.-->     </ControlTemplate>   </Button.Template> </Button> <StackPanel --Define the ControlTemplate here.-->     </ControlTemplate>   </StackPanel.Resources>   <Button Template --Define the ControlTemplate here.-->           </ControlTemplate>         </Setter.Value>       </Setter

    1.2K10发布于 2018-07-25
  • 来自专栏Niuery的技术日记

    WPF --- 重写圆角DataGrid样式

    > </ControlTemplate> </Setter.Value> </Setter> </Style> TargetType="{x:Type Control}"> <Grid /> </ControlTemplate> > </ControlTemplate> </Setter.Value> </Setter> </Style> < > </ControlTemplate> </Setter.Value> </Setter> </Style> > </ControlTemplate> </Setter.Value> </Setter> </Style>

    1.4K20编辑于 2023-10-22
  • 来自专栏码客

    WPF全局样式设置

    " Value="false" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate Opacity" Value="0.2" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TemplateBinding Height}" Fill="{TemplateBinding Background}" /> </ControlTemplate Opacity" Value="0" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate 0" Height="0" Fill="#90000000" /> </ControlTemplate

    2K31发布于 2021-07-30
  • 来自专栏CSharp编程大全

    WPF XAML 为项目设置全局样式

    </Setter.Value> </Setter> </Style> <ControlTemplate x:Key="xx" TargetType="Button "> <Grid></Grid> </ControlTemplate> </ResourceDictionary> </Application.Resources --应用于全局的控件模板--> <Setter.Value> <ControlTemplate TargetType > </ControlTemplate> </Setter.Value> </Setter --<ControlTemplate x:Key="buttonTemplate" TargetType="Button" > <Border BorderThickness

    2.3K41发布于 2021-10-19
  • 来自专栏liulun

    WPF ListView CellTemplate Border---设置ListView单元格的边框

    Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate }}" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate > </ControlTemplate> </Setter.Value> </Setter> true" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate > </ControlTemplate> </Setter.Value> </Setter>

    2.2K20编辑于 2022-05-09
  • 来自专栏CSharp编程大全

    WPF 如何修改button圆角(经典)

    Grid.Column="2" Content="取消" Margin="30,40,200,40" > <Button.Template > <ControlTemplate VerticalAlignment="Center" ></ContentPresenter> </Border> </ControlTemplate VerticalAlignment="Top" Width="472" Height="200" Foreground="White"> <Button.Template> <ControlTemplate LinearGradientBrush> </Button.Background> <Button.Template> <ControlTemplate > </ControlTemplate > </ResourceDictionary > </Window.Resources > <Grid>

    4.1K21发布于 2021-02-26
  • 来自专栏CSharp编程大全

    WPF控件模板

    控件模板ControlTemplate,有两部分:VistualTree视觉树,即是能看到的外观;Trigger触发器,里面包括外部条件达到某一条件下会引起的响应。 Name="button1" VerticalAlignment="Top" Width="205" > <Button.Template > <ControlTemplate > </ControlTemplate > </Button.Template > </Button >  在上面的前台代码中, 为了便于多次利用,可以将其写入模板中,如下: <Window.Resources > <ControlTemplate x:Key="buttonTemplate" TargetType > </ControlTemplate > </Window.Resources > 调用时: <Button Content="Button" Height="23" HorizontalAlignment

    1.5K10发布于 2021-01-28
  • 来自专栏hbbliyong

    WPF模板

    先来个模板: <ControlTemplate x:Key="button" TargetType="Button"> <Border CornerRadius="4" BorderThickness 1.模板绑定 我们希望能够添加一些参数到模板中,或者利用来自模板控件中的属性更进一步地自定义控件, 所以我们可以在模板控件上绑定属性,让控件使用者能够调整控件上的属性并自定义模板,代码如: <ControlTemplate Background}" > <ContentPresenter/> </Border> </ControlTemplate 这样做以后,只需简单 的设置Button上的属性,就可以了创建下图的按钮: <ControlTemplate x:Key="button" TargetType="{x:Type Button}"> Background}" > <ContentPresenter/> </Border> </ControlTemplate

    1.1K40发布于 2018-03-05
  • 来自专栏林德熙的博客

    WPF 修改按钮按下的颜色

    Center" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate ="Foreground" Value="#4DFFFFFF" /> </Trigger> </ControlTemplate.Triggers > </ControlTemplate> </Setter.Value> </Setter> Center" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate > </ControlTemplate> </Setter.Value> </Setter>

    3.7K10编辑于 2022-08-04
  • 来自专栏码客

    WPF桌面端开发-数据绑定(Binding)

    TemplatedParent 此模式允许将给定的 ControlTemplate 属性绑定到应用 ControlTemplate 的控件的属性。 为了更好地理解这里的问题,下面是一个示例 <Window.Resources> <ControlTemplate x:Key="ZTemplate"> <Canvas> {Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" /> </Canvas> </ControlTemplate //schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:TemplateBindingDemo"> <ControlTemplate ResourceDictionary> MyButton.cs public class MyButton : Button { // ... } 在这里,我们为 MyButton 定义了一个 ControlTemplate

    72830编辑于 2023-07-11
  • 来自专栏林德熙的博客

    WPF 修改按钮按下的颜色

    Center" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate ="Foreground" Value="#4DFFFFFF" /> </Trigger> </ControlTemplate.Triggers > </ControlTemplate> </Setter.Value> </Setter> Center" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate > </ControlTemplate> </Setter.Value> </Setter>

    7.2K10发布于 2018-09-19
  • 来自专栏dino.c的专栏

    [UWP 自定义控件]了解模板化控件(4):TemplatePart

    TemplatePart TemplatePart(部件)是指ControlTemplate中的命名元素。 控件逻辑预期这些部分存在于ControlTemplate中,并且使用protected DependencyObject GetTemplateChild(String childName)获取它们后进行操作 从返回值是DependencyObject可以看出,只要是DependencyObject 都能使用ControlTemplate获取。 TemplatePartAttribute协定 有时,为了表明控件期待在ControlTemplate存在某个特定部件,防止编辑ControlTemplate的开发人员删除它,控件上会添加添加TemplatePartAttribute 如果ControlTemplate没有遵循TemplatePartAttribute协定也不应该抛出异常,有可能ControlTemplate的作者是故意屏蔽某项功能。

    1.2K20发布于 2019-01-18
领券