zoukankan      html  css  js  c++  java
  • WPF Dependency property ,overrideMetaData issue

     

    Seems to knowbecause MyStackPanel2 has  register, so will new a property, _metaMap has no base type's metadata, so if we use

     static MyStackPanel2()
            {
                MyStackPanel.IntDataProperty.OverrideMetadata(typeof(MyStackPanel2), new FrameworkPropertyMetadata(9));
     
                MyStackPanel.MinDateProperty.AddOwner(typeof(MyStackPanel2), new FrameworkPropertyMetadata(DateTime.Now, onMindateChange2));
            }

     

    The new metadata will merge basetype's metadata! For attached property, although register’s metaData is only stored at defaultmetaData _metaMap have no but overrideMetaData method will add new metadata to _metaMap, and will do merge too.

    And,MyStackPanel2 is sub class of MyStackPanel, so the merge will happen, if not sub class ,the merge will not happen either.like the code below:

    public partial class UserControlLabel : Label
    {
    static UserControlLabel()
            {
                MyStackPanel.MinDateProperty.OverrideMetadata(typeof(UserControlLabel), new FrameworkPropertyMetadata(DateTime.Now, onMinDateChangeUserControl));
     }
     
            public DateTime MinDate
            {
                get { return (DateTime)GetValue(MyStackPanel.MinDateProperty); }
                set { SetValue(MyStackPanel.MinDateProperty, value); }
            }
    }
     
    2. 

    This PropertyFromName hashtable is mainly use by the xaml->code process

    which can be found by analyzing the DependencyProperty.FromName() method using reflectors use by function..

    3. attched property register not use overridemetedata, because its ownertype can not be dependencyObject, _metadataMap need to use 
    DependencyObjectType.typeId as key.
    
  • 相关阅读:
    [CISCN2019 总决赛 Day2 Web1]Easyweb
    [极客大挑战 2019]Upload
    [SUCTF 2019]EasyWeb
    2020/2/1 PHP代码审计之任意文件读取及删除漏洞
    2020/1/31 PHP代码审计之文件包含漏洞
    [Luogu P1120]小木棍·加强版
    学习笔记·堆优化$mathscr{dijkstra}$
    [LuoguP1462]通往奥格瑞玛的道路($SPFA+$二分)
    [USACO08JAN]电话线$Telephone Lines$(图论$+SPFA+$ 二分答案)
    [USACO06NOV]玉米田$Corn Fields$ (状压$DP$)
  • 原文地址:https://www.cnblogs.com/liangouyang/p/1260954.html
Copyright © 2011-2022 走看看