当前位置: 首页>>代码示例>>C#>>正文


C# PropertyChangedEventHandler类代码示例

本文整理汇总了C#中PropertyChangedEventHandler的典型用法代码示例。如果您正苦于以下问题:C# PropertyChangedEventHandler类的具体用法?C# PropertyChangedEventHandler怎么用?C# PropertyChangedEventHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PropertyChangedEventHandler类属于命名空间,在下文中一共展示了PropertyChangedEventHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PropertyChangedRegistration

        /// <summary>Initializes a new instance of the <see cref="PropertyChangedRegistration"/> class.</summary>
        /// <param name="handler">The handler to which all change notifications are forwarded.</param>
        /// <param name="properties">The properties for which change notifications should be forwarded.</param>
        /// <exception cref="ArgumentException">One or more elements of <paramref name="properties"/> equal <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentNullException"><paramref name="handler"/> and/or <paramref name="properties"/>
        /// equal <c>null</c>.</exception>
        /// <remarks>After construction, each change to one of the properties in <paramref name="properties"/> is
        /// forwarded to <paramref name="handler"/> until <see cref="Dispose"/> is called.</remarks>
        public PropertyChangedRegistration(
            PropertyChangedEventHandler handler, params IProperty<INotifyPropertyChanged>[] properties)
        {
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            if (Array.IndexOf(properties, null) >= 0)
            {
                throw new ArgumentException("Array elements cannot be null.", nameof(properties));
            }

            this.handler = handler;
            this.propertyNames = properties.ToLookup(p => p.Owner, p => p.PropertyInfo.Name);

            foreach (var grouping in this.propertyNames)
            {
                grouping.Key.PropertyChanged += this.OnPropertyChanged;
            }
        }
开发者ID:Lawo,项目名称:ember-plus-sharp,代码行数:35,代码来源:PropertyChangedRegistration.cs

示例2: Bind

        public static Action Bind(this UISwitch toggle, INotifyPropertyChanged source, string propertyName)
        {
            var property = source.GetProperty(propertyName);

            if (property.PropertyType == typeof(bool))
            {
                toggle.SetValue(source, property);
                var handler = new PropertyChangedEventHandler ((s, e) =>
                {
                    if (e.PropertyName == propertyName)
                    {
                            toggle.InvokeOnMainThread(()=>
                                toggle.SetValue(source, property));
                    }
                });

                source.PropertyChanged += handler;

                var valueChanged = new EventHandler(
                    (sender, e) => property.GetSetMethod().Invoke (source, new object[]{ toggle.On }));

                toggle.ValueChanged += valueChanged;

                return new Action(() =>
                {
                    source.PropertyChanged -= handler;
                    toggle.ValueChanged -= valueChanged;
                });
            } 
            else
            {
                throw new InvalidCastException ("Binding property is not boolean");
            }
        }
开发者ID:Qwin,项目名称:SimplyMobile,代码行数:34,代码来源:SwitchExtensions.cs

示例3: Intercept

        public override void Intercept(IInvocation invocation)
        {
            // WPF will call a method named add_PropertyChanged to subscribe itself to the property changed events of
            // the given entity. The method to call is stored in invocation.Arguments[0]. We get this and add it to the
            // proxy subscriber list.
            if (invocation.Method.Name.Contains("PropertyChanged"))
            {
                PropertyChangedEventHandler propertyChangedEventHandler = (PropertyChangedEventHandler)invocation.Arguments[0];
                if (invocation.Method.Name.StartsWith("add_"))
                {
                    subscribers += propertyChangedEventHandler;
                }
                else
                {
                    subscribers -= propertyChangedEventHandler;
                }
            }

            // Here we call the actual method of the entity
            base.Intercept(invocation);

            // If the method that was called was actually a proeprty setter (set_Line1 for example) we generate the
            // PropertyChanged event for the property but with event generator the proxy. This must do the trick.
            if (invocation.Method.Name.StartsWith("set_"))
            {
                subscribers(invocation.InvocationTarget, new PropertyChangedEventArgs(invocation.Method.Name.Substring(4)));
            }
        }
开发者ID:MatiasBjorling,项目名称:EcoLoad,代码行数:28,代码来源:DataBindingIntercepter.cs

示例4: PlayerView

 public PlayerView()
 {
     InitializeComponent();
     this.DataContextChanged += new DependencyPropertyChangedEventHandler(PlayerInfoView_DataContextChanged);
     _OnPropertyChanged = new PropertyChangedEventHandler(model_PropertyChanged);
     Unloaded += PlayerView_Unloaded;
 }
开发者ID:kingling,项目名称:sgs,代码行数:7,代码来源:PlayerView.xaml.cs

示例5: Book

 public Book(string author, string name, int year, PropertyChangedEventHandler propertyChanged)
 {
     this.author = author;
     this.name = name;
     this.year = year;
     PropertyChanged = propertyChanged;
 }
开发者ID:abdonkov,项目名称:HackBulgaria-CSharp,代码行数:7,代码来源:Book.cs

示例6: MainPlayerView

 public MainPlayerView()
 {
     InitializeComponent();
     this.DataContextChanged += new DependencyPropertyChangedEventHandler(PlayerInfoView_DataContextChanged);
     _OnPropertyChanged = new PropertyChangedEventHandler(model_PropertyChanged);
     handCardArea.OnHandCardMoved += handCardArea_OnHandCardMoved;
 }
开发者ID:maplegh,项目名称:sgs,代码行数:7,代码来源:MainPlayerView.xaml.cs

示例7: Bind

        public static PropertyChangedEventHandler Bind(this SeekBar seekBar, INotifyPropertyChanged source, string propertyName)
        {
            var property = source.GetProperty(propertyName);

            var r = property.GetCustomAttribute<RangeAttribute> ();

            if (r != null)
            {
                seekBar.Max = (int)r.Maximum;
            }

            var handler = new PropertyChangedEventHandler ((s, e) =>
                {
                    if (e.PropertyName == propertyName)
                    {
                        //textField.SetText(source, property);
                    }
                });

            source.PropertyChanged += handler;

            //textField.AfterTextChanged += (sender, e) => property.GetSetMethod().Invoke(source, new []{textField.Text});

            return handler;
        }
开发者ID:Qwin,项目名称:SimplyMobile,代码行数:25,代码来源:SeekBarExtensions.cs

示例8: Composition

 public Composition(string path, PropertyChangedEventHandler PropertyChanged)
 {
     this.PropertyChanged += PropertyChanged;
     FileInfo = TagLib.File.Create(path);
     if (FileInfo.Tag.Artists.Length == 0)
         Artists = "Unknown artist";
     else
     {
         foreach (string str in FileInfo.Tag.Artists)
         {
             Artists += str;
             Artists += "; ";
         }
         Artists = Artists.Substring(0, Artists.Length - 2);
     }
     if (FileInfo.Tag.Title == null)
         Title = "Unknown title";
     else
         Title = FileInfo.Tag.Title;
     if (FileInfo.Tag.Album == null)
         Album = "Unknown album";
     else
         Album = FileInfo.Tag.Album;
     Name = FileInfo.Name;
     Image = new BitmapImage();
     Image.BeginInit();
     if (FileInfo.Tag.Pictures.Length != 0)
         Image.StreamSource = new MemoryStream(FileInfo.Tag.Pictures[0].Data.Data);
     else
         Image.UriSource = new Uri("Content\\note-blue.png", UriKind.RelativeOrAbsolute);
     Image.EndInit();
 }
开发者ID:nikoir,项目名称:AudioPlayer,代码行数:32,代码来源:Composition.cs

示例9: AddPropertyChangedListener

 public object AddPropertyChangedListener( object target, PropertyChangedEventHandler listener ) {
     EventHandler changedHandler = ( sender, args ) => {
         listener.Invoke( this, new PropertyChangedEventArgs( "S" ) );
     };
     ( ( TargetClass ) target ).SChanged += changedHandler;
     return changedHandler;
 }
开发者ID:furesoft,项目名称:consoleframework,代码行数:7,代码来源:AdapterTest.cs

示例10: ProfilingTargetView

        /// <summary>
        /// Create a ProfilingTargetView with default values.
        /// </summary>
        public ProfilingTargetView() {
            var solution = NodejsProfilingPackage.Instance.Solution;
            
            var availableProjects = new List<ProjectTargetView>();
            foreach (var project in solution.EnumerateLoadedProjects(onlyNodeProjects: true)) {
                availableProjects.Add(new ProjectTargetView((IVsHierarchy)project));
            }
            _availableProjects = new ReadOnlyCollection<ProjectTargetView>(availableProjects);

            _project = null;
            _standalone = new StandaloneTargetView();
            _isProjectSelected = true;

            _isValid = false;

            PropertyChanged += new PropertyChangedEventHandler(ProfilingTargetView_PropertyChanged);
            _standalone.PropertyChanged += new PropertyChangedEventHandler(Standalone_PropertyChanged);

            var startupProject = NodejsProfilingPackage.Instance.GetStartupProjectGuid();
            Project = AvailableProjects.FirstOrDefault(p => p.Guid == startupProject) ??
                AvailableProjects.FirstOrDefault();
            if (Project != null) {
                IsStandaloneSelected = false;
                IsProjectSelected = true;
            } else {
                IsProjectSelected = false;
                IsStandaloneSelected = true;
            }
            _startText = Resources.ProfilingStart;
        }
开发者ID:munyirik,项目名称:nodejstools,代码行数:33,代码来源:ProfilingTargetView.cs

示例11: MainPage

        // Constructeur
        public MainPage()
        {
            InitializeComponent();
            this.Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentCulture.Name);
            Failure_Handler = new PropertyChangedEventHandler(FailureOccured);

            _viewModel = DataContext as MainPageVM;
            _viewModel.PropertyChanged += VM_PropertyChanged;

            ViewModelLocator.Client.PropertyChanged += Failure_Handler;

            version_text.Text = Helper.GetVersionNumber();

            ApplicationBar.Buttons.Add(new ApplicationBarIconButton()
            {
                Text = AppLanguage.AppBar_Refresh,
                IconUri = new Uri("/icons/appbar.refresh.rest.png", UriKind.Relative)
            });
            (ApplicationBar.Buttons[0] as ApplicationBarIconButton).Click += Sync_Btn_Click;

            ApplicationBar.MenuItems.Add(new ApplicationBarMenuItem(AppLanguage.AppBar_Settings));
            (ApplicationBar.MenuItems[0] as ApplicationBarMenuItem).Click += SettingsPage_Click;
#if DEBUG
            ApplicationBar.MenuItems.Add(new ApplicationBarMenuItem("[DEV] CLEAR"));
            (ApplicationBar.MenuItems[1] as ApplicationBarMenuItem).Click += DEV_clrDB_Click ;
#endif
        }
开发者ID:Okhoshi,项目名称:Claroline.WindowsPhone,代码行数:28,代码来源:MainPage.xaml.cs

示例12: Student

 public Student(string name, int age)
 {
     this.args = new ModifiedEventArgs();
     this.onChange += new PropertyChangedEventHandler(ActionPerformed);
     this.Name = name;
     this.Age = age;
 }
开发者ID:shnogeorgiev,项目名称:Software-University-Courses,代码行数:7,代码来源:Student.cs

示例13: DefaultableSettings

 protected internal DefaultableSettings(DefaultSettings defaultSettings, PropertyChangedEventHandler eventHandler = null)
 {
     DefaultSettings = defaultSettings;
     PropertyBag = new PropertyBagCollection<DefaultBoolean>(DefaultBoolean.Default, RaisePropertyChanged);
     if (null != eventHandler)
         this.PropertyChanged += eventHandler;
 }
开发者ID:netintellect,项目名称:NetOffice,代码行数:7,代码来源:DefaultableSettings.cs

示例14: ProfilingTargetView

        /// <summary>
        /// Create a ProfilingTargetView with default values.
        /// </summary>
        public ProfilingTargetView(IServiceProvider serviceProvider) {
            var solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            
            var availableProjects = new List<ProjectTargetView>();
            foreach (var project in solution.EnumerateLoadedProjects()) {
                availableProjects.Add(new ProjectTargetView((IVsHierarchy)project));
            }
            _availableProjects = new ReadOnlyCollection<ProjectTargetView>(availableProjects);

            _project = null;
            _standalone = new StandaloneTargetView(serviceProvider);
            _isProjectSelected = true;

            _isValid = false;

            PropertyChanged += new PropertyChangedEventHandler(ProfilingTargetView_PropertyChanged);
            _standalone.PropertyChanged += new PropertyChangedEventHandler(Standalone_PropertyChanged);

            var startupProject = PythonProfilingPackage.GetStartupProjectGuid(serviceProvider);
            Project = AvailableProjects.FirstOrDefault(p => p.Guid == startupProject) ??
                AvailableProjects.FirstOrDefault();
            if (Project != null) {
                IsStandaloneSelected = false;
                IsProjectSelected = true;
            } else {
                IsProjectSelected = false;
                IsStandaloneSelected = true;
            }
            _startText = "_Start";
        }
开发者ID:omnimark,项目名称:PTVS,代码行数:33,代码来源:ProfilingTargetView.cs

示例15: OpenFileLocalization

 internal OpenFileLocalization(PropertyChangedEventHandler eventHandler = null)
 {
     PropertyBag = new PropertyBagCollection<string>("<Empty>", RaisePropertyChanged);
     Set1033Default(null, new EventArgs());
     if (null != eventHandler)
         this.PropertyChanged += eventHandler;
 }
开发者ID:netintellect,项目名称:NetOffice,代码行数:7,代码来源:OpenFileLocalization.cs


注:本文中的PropertyChangedEventHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。