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. 【VUE+laravel5.4】vue给http请求 添加请求头数据

    1.适用于 ajax和普通的http请求 2.vue添加用法如下: <script type="text/javascript src="/dist/js/app.min.j ...

  2. 马老师 linux必备web服务入门及高级进阶

    http://edu.51cto.com/course/course_id-866.html HTTP: HyperText Transfer Protocol 超文本传输协议 超链接: Web: h ...

  3. UltraEdit打开中文乱码

    http://hellofs.blog.51cto.com/6109153/1187548 UltraEdit很强大,但是今天发现在打开含有中文的文本时会乱码,还是在配置里找找相关的设置,可以在如图的 ...

  4. PMP考试终于结束了。。。

    PMP考试昨天终于结束了,可以好好的先休息下了,先不管成绩了,通过这段时间的学习了解,发现PMP在实际工作中的运用 起的作用还很大,看样子以后要学习的东西还多着呢,先休息一周再说...

  5. Symantec Backup Exec(BE)的启停

    # /etc/init.d/VRTSralus.init start Starting Symantec Backup Exec Remote Agent ...... Starting Symant ...

  6. configure: error: png.h not found.

    PHP的时候提示这个错误 configure: error: png.h not found.,这个是选择安装GD模块才会出现的错误,详细错误信息如下 If configure fails try - ...

  7. OAF_OAF Framework常用函数汇总(概念)

    2014-12-31 Created By BaoXinjian

  8. Form_Form Builder的基本语法(概念)

    2014-05-21 Created By BaoXinjian

  9. HTTP请求流程(二)----Telnet模拟HTTP请求

    http://www.cnblogs.com/stg609/archive/2008/07/06/1237000.html 上一部分"流程简介", 我们大致了解了下HTTP请求的流 ...

  10. django中templates阅读笔记

    一.基本知识 1.模版是独立于django的,可以独立运行. 模版变量是用两个大括号括起来的字符串,表示变量.例如{{ person_name }} 模版标签,是用一对大括号和一对百分号括起来的,例如 ...