ContentControl有两个属性:

        // 摘要:
// 获取或设置 System.Windows.Controls.ContentControl 依赖项属性的值。
//
// 返回结果:
// 一个包含控件内容的对象。默认值为 null。
public object Content { get; set; }
//
// 摘要:
// 获取或设置用于显示 System.Windows.Controls.ContentControl 内容的数据模板。
//
// 返回结果:
// 用于显示 System.Windows.Controls.ContentControl 内容的数据模板。
public DataTemplate ContentTemplate { get; set; }

Content用来表示其内容,可以是控件控件笔刷文字等内容,ContentTemplate为DataTemplate类型的模板,其为显示效果。

Control和FrameElement的去别在于前者有Template属性。

            <Button Content="Click me!" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button.Style>
<Style TargetType="Button">
<Setter Property="BorderBrush" Value="{StaticResource PhoneAccentBrush}" />
<Setter Property="BorderThickness" Value="" />
<Setter Property="Background" Value="{StaticResource PhoneChromeBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="">
    <ContentPresenter Content="{TemplateBinding Content}"
                                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                                          Margin="{TemplateBinding Padding}"
                                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> </Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>

ContentPresenter刚好对应control中的两个属性Content和ContentTemplate。object类型的Content与其相一致,当button中的属性不会受ContentPresenter的控制时,

说明Button的属性是本身的熟悉,需要绑定。如ForeGround,是字体的属性,直接就在Content里面一起绑定了。如BackGround是Button的属性,非内容属性。

/// <summary>
/// 遍历指定的UIControl里面的元素——引用方式DumpVisualTree(listBox, 0);
/// </summary>
/// <param name="parent"></param>
/// <param name="indent"></param>
void DumpVisualTree(DependencyObject parent, int indent)
{
TextBlock txtblk = new TextBlock();
txtblk.Text = String.Format("{0}{1}", new string(' ', * indent),
parent.GetType().Name);
dumpTreeItemsControl.Items.Add(txtblk); int numChildren = VisualTreeHelper.GetChildrenCount(parent); for (int childIndex = ; childIndex < numChildren; childIndex++)
{
DependencyObject child = VisualTreeHelper.GetChild(parent, childIndex);
DumpVisualTree(child, indent + );
}
}

WP模板的更多相关文章

  1. wordpress 模板制作之一

    WP模板工作原理图:

  2. 记一次wordpress安装过程中遇到的问题及解决办法

    Q:无法建立目录wp-content/uploads/2017/03.有没有上级目录的写权限?A:执行chmod 777 wp-content/ 提升目录权限 Q:安装主题或安装插件的时候,用到FTP ...

  3. 2021年Wordpress手把手教你做个独立站——部署篇

    2021年Woocommerce电商主题的安装部署教程 Woocommerce是一个Wordpress的一个流行的电商插件.完成Wordpress的安装即已完成80%.剩下的便是去寻找一款合适的自己喜 ...

  4. WP主题模板制作修改教程

    WP主题模板制作修改教程 实际上,当我们打开某个主题的文件夹时,看到的并不止这两个文件,而是更多.但一般来说,在一个完整的 WP 主题文件夹中都应该包含下列文件(也称为模板文件):页面 模板文件 用途 ...

  5. wpf/Silverlight/wp中如何绑定模板中的属性

    <Style TargetType="{x:Type TabItem}" x:Key="EditorTabItemStyle"> <Sette ...

  6. 关于 WP 开发中.xaml 与.xaml.cs 的关系

    今天我们先来看一下在WP8.1开发中最长见到的几个文件之间的关系.比较论证,在看这个问题之前我们简单看看.NET平台其他两个不同的框架: Windows Forms 先看看Window Forms中的 ...

  7. discuz模板语法

    Discuz! X 模板的解析主要是 ./source/class/class_template.php 文件解析处理的,如果需要深入了解请可以看看这个文件! 模板嵌套语法 将被嵌套模板内容解析为 P ...

  8. 【WP开发】读写剪贴板

    在WP 8.1中只有Silverlight App支持操作剪贴板的API,Runtime App并不支持.不过,在WP 10中也引入了可以操作剪贴板的API. 顺便说点题外话,有人会说,我8.1的开发 ...

  9. 【WP 8.1开发】一键锁屏

    在WP8的时候,关于如何关闭屏幕,国内外都有不少文章了,大家有兴趣地可以搜搜,很多,我就不给链接了,因为稍后我的例子中会有. 其实,关闭屏幕是调用了未开放的API,正因为这个API未开放的,不敢保证所 ...

随机推荐

  1. 两个有序数组求中位数log(m+n)复杂度

    leetcode 第4题 中位数技巧: 对于长度为L的有序数组,它的中位数是(a[ceil((L+1)/2)]+a[floor((L+1)/2)])/2 算法原理: 类似三分法求极值 两个人都前进,谁 ...

  2. Eclipse 去掉JavaScript Validator

    http://www.cnblogs.com/wucg/archive/2012/08/06/2625458.html eclipse有些时候,javascript文件总是通不过eclipse的编译校 ...

  3. 【php】基础学习3

    本节主要是php中函数的学习: <html xmlns=http://www.w3.org/1999/xhtml> <head> <meta http-equiv=Con ...

  4. c#基础之异常处理及自定义异常 从SQLServer转储数据到MySQL

    c#基础之异常处理及自定义异常 一.什么是c#中的异常? 异常是程序运行中发生的错误,异常处理是程序的一部分.c#中的异常类主要是直接或者间接的派生于 System.Exception类 ,也就是说S ...

  5. Linux内核(9) - 精华版 之 方法论

    到目前为之,博客上分享的精华篇都可以归为方法论的范畴,在很多时候,都是方法论要比细节紧要得多.而这些精华篇又可细分为三个专题:Linux大史记:内核学习的方法论:驱动开发的方法论. Linux大史记 ...

  6. Python log() 函数

    描述 log() 方法返回x的自然对数,x > 0. 语法 以下是 log() 方法的语法: import math math.log( x ) 注意:log()是不能直接访问的,需要导入 ma ...

  7. winfrom 窗口起始位置为屏幕中央

    窗口起始位置为屏幕中央 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; 获取鼠标触发事件光标位置 t ...

  8. graphite的安装文档

    http://www.th7.cn/Program/Python/201603/783804.shtml https://lanjingling.github.io/2016/04/04/graphi ...

  9. TreeMap升序|降序排列和按照value进行排序

    TreeMap 升序|降序排列 import java.util.Comparator; import java.util.TreeMap; public class Main { public st ...

  10. java.lang.IllegalStateException: The specified child already has a parent. You must call removeView

     java.lang.IllegalStateException: The specified child already has a parent. You must call removeVi ...