zoukankan      html  css  js  c++  java
  • WP7备注(14)(ContentPropertyAttribute)

    ContentPropertyAttribute主要用于Xaml的简化.

    <TextBlock.Foreground>
    <RadialGradientBrush>
    <RadialGradientBrush.GradientStops>
    <GradientStopCollection>
    <GradientStop Offset="0" Color="Transparent" />
    <GradientStop Offset="1" Color="Red" />
    </GradientStopCollection>
    </RadialGradientBrush.GradientStops>
    </RadialGradientBrush>
    </TextBlock.Foreground>

    首先剔除GradientStopCollenction

    <TextBlock.Foreground>
    <RadialGradientBrush>
    <RadialGradientBrush.GradientStops>
    <GradientStop Offset="0" Color="Transparent" />
    <GradientStop Offset="1" Color="Red" />
    </RadialGradientBrush.GradientStops>
    </RadialGradientBrush>
    </TextBlock.Foreground>

    其次,因为

    [ContentPropertyAttribute("GradientStops", true)]
    public abstract class GradientBrush : Brush

    所以,可以剔除RadialGradientBrush.GradientStops,变成

    <TextBlock.Foreground>
    <RadialGradientBrush>
    <GradientStop Offset="0" Color="Transparent" />
    <GradientStop Offset="1" Color="Red" />
    </RadialGradientBrush>
    </TextBlock.Foreground>

    --------------------------------------------------------------------------------------------------

    又如

    [ContentPropertyAttribute("Children", true)]
    public abstract class Panel : FrameworkElement
    
    [ContentPropertyAttribute("Content", true)]
    public class UserControl : Control

    都是给与Xaml元素默认的可省略内部元素标签

  • 相关阅读:
    类与类之间的几种关系
    spring之BeanFactory
    java打开本地应用程序
    java笔记六:线程间的协调
    继承与组合的优缺点
    适配器模式之对象适配器
    java笔记三:List接口
    java笔记二:final关键字用法总结
    设计模式之命令模式
    利用栈实现迷宫的求解
  • 原文地址:https://www.cnblogs.com/otomii/p/2031420.html
Copyright © 2011-2022 走看看