zoukankan      html  css  js  c++  java
  • Binding 依赖属性定义

    class BackgroundPath:Image
        {
            public event PropertyChangedEventHandler PropertyChanged;
            static BackgroundPath()
            {
                BindSourceProperty =
                DependencyProperty.Register("BindSource",
                typeof(BitmapImage),
                typeof(BackgroundPath),
                new PropertyMetadata(new BitmapImage(new Uri(PathShow.ImageSelected)), OnBitmapImageChanged));
            }
    
            public BitmapImage BindSource
            {
                get
                {   return (BitmapImage)GetValue(BindSourceProperty);}
                set
                {   SetValue(BindSourceProperty, value);}
            }
            public static DependencyProperty BindSourceProperty { private set; get; }
    
            static void OnBitmapImageChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
            {
                (obj as BackgroundPath).OnBitmapImageChanged(args);
            }
    
            void OnBitmapImageChanged(DependencyPropertyChangedEventArgs args)
            {
                if (args.Property == BindSourceProperty)
                    BindSource = (BitmapImage)args.NewValue;
            }
        }
    
    
     Binding bind = new Binding()
                {
                    Source = new BackgroundPath(),
                    Path = new PropertyPath("BindSource")
                };
                faceImge.SetBinding(Image.SourceProperty,bind);
  • 相关阅读:
    HDU 4393 Throw nails(贪心加模拟,追及问题)
    【Add Two Numbers】
    【Single Num II】cpp
    【Single Number】cpp
    【Candy】cpp
    【Gas Station】cpp
    【Set Matrix Zeros】cpp
    【Gray Code】cpp
    【Climbing Stairs】cpp
    【Plus One】cpp
  • 原文地址:https://www.cnblogs.com/yunqie/p/7002314.html
Copyright © 2011-2022 走看看