ComponentOne Scheduler for WPF: Using Scheduler for WPF > Scheduler for WPF Appearance > Enhancing the User Interface with Method Calls

Enhancing the User Interface with Method Calls

Just getting or setting properties is not enough to provide a fully-functional user interface. Often method calls are necessary. The Windows Presentation Foundation (WPF) provides the ObjectDataProvider class, which is intended to allow you to perform method or constructor calls declaratively in XAML. However, the ObjectDataProvider properties that define what method with what parameters on which object to call are not DependencyProperties, so binding to them, if possible, is difficult. Trigger Setters can't be used to define these properties. Also, there is no convenient way to control when the call should be performed; it happens each time one of the properties has been changed.

The MethodCaller class provides similar behavior to WPF's ObjectDataProvider, but its properties are DependencyProperties, allowing you to conveniently bind to them and use them in Trigger Setters. Because it's derived from the FrameworkElement class, like the PropertyBridge class, the MethodCaller class can be placed in the visual tree which allows bindings to work properly.

In addition to the features provided by ObjectDataProvider, the MethodCaller class provides the following:

      MethodParameters(), MethodParameters1, MethodParameters2, and so on are dependency properties, instead of a collection of parameters, which allows you to define method parameters via binding.

      The Boolean Call dependency property. A method or a constructor call is performed when this property changes its value from False to True. It can be set from within a trigger or at a fully controlled time when the method is called, for example, when bound to the IsPressed property of Button.

      The Boolean PermanentCall property. When set to True, PermanentCall forces the MethodCaller class to work in the same manner as the ObjectDataProvider class. In other words, a call is performed each time some of its properties have been changed.


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.