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. Web服务器(容器)请求常见的错误及其解决方法

    首先我们来看看容器如何找到service()方法?(1)当在浏览器中输入 http://localhost:8080/firstweb/sayHi 这个地址后,容器是如何找到 HelloServlet ...

  2. 【WebKit内核 CEF3 】 第一篇:下载分支代码并本地编译

    关于CEF  Chromium Embedded Framework 简单说就是  WebKit内核的 对外绑定. 当前主流浏览器内核 一.Trident内核代表产品Internet Explorer ...

  3. Androidmanifest.xml在Android项目中的作用

    以下是一个项目中的AndroidManifest.xml文件: <?xml version="1.0" encoding="utf-8"?> < ...

  4. Android API之android.provider.ContactsContract.Contacts

    android.provider.ContactsContract.Contacts 对应contacts数据表.RawContacts的一个聚合(aggregate)代表同一个人.每个人在数据表co ...

  5. PHP反射获取当前函数的内容

    <?php $test = function () { echo 'hello world'; }; function closure_dump($closure) { try { $func ...

  6. 【转载】delphi下如何复制文件

    1. CopyFile(PChar(源目录),PChar(目标目录),True); CopyFileTo('F:\MyProject\delphi\message\data\data.mdb','c: ...

  7. SqlServer强制断开数据库已有连接的方法(转)

    在master数据库中执行如下代码 declare @i INT  declare cur cursor for select spid from sysprocesses where db_name ...

  8. MFC图形绘制——绘制直尺和坐标系

    一.实验目的 1.掌握建立MFC应用程序的方法: 2.掌握映射模式. 二.实验内容 1.在MFC中绘制直尺,直尺需要有刻度,类似于日常学生使用的透明塑料直尺,需要建立四个直尺,分别分布在屏幕客户区的上 ...

  9. Chart.js 学习笔记

    1.引入Chart.js 文件 <script src="Chart.js"></script> 2.在html中创建画布 <canvas id=&q ...

  10. jquery动态绑定事件

    什么是动态绑定? 动态绑定是指动态添加的DOM节点或者html元素,他们最开始时运行的时候是不存在的.如果要给这些动态加入的节点增加事件,就必须要用jquery的on方法来绑定事件. $('.cont ...