- 浏览: 399741 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (309)
- xaml C# wpf (0)
- scala java inner clas (1)
- Tools UML Eclipse UML2 (1)
- Timer .NET Framework (1)
- perl (6)
- python function paramter (1)
- Python Docstring (1)
- Python how to compare types (1)
- Python (8)
- java (5)
- C# (76)
- C# WPF (0)
- p4 (0)
- WPF (46)
- .net (6)
- xaml (1)
- javascript (40)
- windows (10)
- scala (4)
- winform (1)
- c++ (48)
- tools (12)
- cmd (1)
- os (0)
- CI (0)
- shell (0)
- C (2)
- haskell (49)
- functional (1)
- tool (1)
- gnu (1)
- linux (1)
- kaskell (0)
- svn (0)
- wcf (3)
- android (1)
最新评论
from MSDN:
PropertyDescriptor provides an abstraction of a property on a class
DepednencyPropertyDescriptor provides an extension to PropertyDescriptor that accounts for the additional property characteristics of a dependency property.
Suppose, there is a dependency property that is called "PersistenceConfigurationProperty", and it is declared in a WindowPersistence class.
public static readonly DependencyProperty PersistenceConfigurationProperty = DependencyProperty.RegisterAttached( "PersistenceConfiguration", typeof(ApplicationPersistence), typeof(WindowPersistence), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits, OnSetPersistenceConfigurationCallback));
and in one of the extension class that is called PersistableResourceExtension, with the help of DependencyPropertyDescriptor, we can remove the Value Changed Handler.
DependencyPropertyDescriptor persistenceConfigurationProperty = DependencyPropertyDescriptor.FromProperty( WindowPersistence.PersistenceConfigurationProperty, m_targetObject.GetType()); persistenceConfigurationProperty.RemoveValueChanged(m_targetObject, PersistenceConfigurationPropertyChanged);
There is another examples that use reflection and other things to change the Bindings on a DependencyProperty
if (profileWarningWindow != null) { DependencyPropertyDescriptor persistenceConfiguration = DependencyPropertyDescriptor.FromProperty(WindowPersistence.PersistenceConfigurationProperty, typeof(AdminShellWindow)); if (persistenceConfiguration != null) { Type windowPersistenceType = typeof(WindowPersistence); if (windowPersistenceType != null) { var method = windowPersistenceType.GetMethod("OnSetPersistenceConfigurationCallback", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); if (method != null) { var handler = (PropertyChangedCallback)Delegate.CreateDelegate(typeof(PropertyChangedCallback), method); persistenceConfiguration.RemoveValueChanged(null, handler); } } }
The code above does not necessary means a workable code, there are something that prevent it working (either compile time or runtime);
persistenceConfiguration.RemoveValueChanged(null, handler)
the required type for the second parameter of RemoveValueChanged is EventHandler.
While you cannot convert the PropertyChangedCallback to EventHandler.
发表评论
-
wpf - example to enhance ComboBox for AutoComplete
2014-09-19 15:56 1976first let’s see an example ... -
WPF – Virtualization – VirutalizationStackPanel and ItemsPanelTemplate
2013-08-05 21:55 1410Topic: WPF – Virtualization – ... -
wpf - BehaviorBase and one use examples
2013-06-18 18:41 1311Behavior is something that we ... -
WPF - Setting foreground color of Entire window
2013-06-13 16:00 1918You might as well as I would s ... -
WPF - Enhanced TabControl - TabControlEx aka Prerendering TabControl
2013-06-13 13:12 5330As an opening word, let's che ... -
wpf - ControlTemplate and AddLogicChild/RemoveLogicalChild
2013-06-10 15:42 1185Recently I was trying to debug ... -
wpf - default implicit style
2013-05-10 10:24 794We know that if you left out ... -
wpf - Style setter on the attached property
2013-05-08 14:54 2851I believe that you are familia ... -
wpf - specify enum values in xaml
2013-05-08 11:31 3585Many a situation you find tha ... -
wpf - IG xamDataGrid bind to XmlDataProvider with Xml Island
2012-12-18 14:28 1286Sometimes you may bind to some ... -
wpf - translate winform button/mouse event to wpf events
2012-12-12 17:37 2162It is common that we sometimes ... -
wpf - Freezable and its meaning
2012-09-27 12:38 0This article is based on the di ... -
wpf - Customize the grid lines for original wpf Grid control
2012-09-27 12:01 1458The System.WIndows.Controls.Gri ... -
c# - Convert from System.Drawing.Image to System.WIndows.Media.ImageSource
2012-09-25 14:27 7417In Previous discussion, we have ... -
wpf - Get Effective DependencyProperty value on a DependencyObject
2012-08-28 19:05 1044As discussed in my previous pos ... -
wpf - Default(Theme) style and its DefaultStyleKey
2012-08-28 17:54 1387As dicsused in the subsection o ... -
wpf - Dependency Property Value Precedence
2012-08-28 18:56 882A dependency property to an Dep ... -
wpf - WPF TemplateBinding vs RelativeSource TemplatedParent
2012-08-28 14:20 3713This is a post that summarizes ... -
wpf - ICutomTypeDescriptor , PropertyDescriptor and its use in PropertyGrid
2012-08-28 14:04 3580The type ICustomTypeDe ... -
wpf - tips to convert UI controls in WPF/Silverlight/Winforms into a Bitmap
2012-08-27 17:44 975In previous discussion, we have ...
相关推荐
`PropertyDescriptor`是JavaBeans API的一部分,主要用于处理JavaBean属性。本文将详细介绍如何使用`PropertyDescriptor`通过反射来调用Java对象的`set`和`get`方法。 首先,让我们了解`PropertyDescriptor`。`...
例如,你可以创建一个自定义`PropertyDescriptor`子类,覆盖其`CanResetValue`、`GetValue`、`SetValue`等方法,然后在运行时将它添加到`PropertyGrid`的`Attributes`集合中。 2. **Globalization**: 全球化...
`PropertyDescriptor`是`System.ComponentModel`命名空间中的类,它代表了对象的一个属性,并提供了读取和写入属性值的方法。 ```csharp PropertyDescriptor descriptor = new CustomPropertyDescriptor(...
- 这个方法的作用是根据传入的类`clazz`和属性名`propertyName`,返回一个`PropertyDescriptor`对象。 - 首先尝试获取类中的字段,如果找不到对应的字段,则构建`get`和`set`方法名。 - 使用反射机制查找对应的`...
在.NET Framework中,C#的DataGridView控件是一个用于显示数据集的强大工具,它允许用户以表格形式查看和编辑数据。然而,标准的DataGridView控件仅支持单层表头,这在处理复杂的数据结构时可能会显得不够用。...
//import java.beans.PropertyDescriptor; import com.googlecode.openbeans.BeanInfo; import com.googlecode.openbeans.IntrospectionException; import com.googlecode.openbeans.Introspector; import ...
首先,我们需要为每个属性创建合适的`PropertyDescriptor`,然后找到对应的`PropertyEditor`,并使用`PropertyDescriptor`的`setValue()`方法将Map中的值设置到对应的属性上。以下是一个简化版的实现: ```java ...
Java基础类库,也就是Java doc里面看到的所有的类的class文件。
3. PropertyDescriptor子类:实现自定义的PropertyDescriptor类,如MyPropertyDescriptor,用于处理自定义属性的读写操作和设计时行为。 4. 示例应用程序:一个简单的WinForm应用程序,展示了如何使用这个自定义属性...
然后,创建一个自定义的`PropertyGrid`类,如`LocalizedPropertyGrid`,并在其中重写`CreateProperty`方法,使用`LocalizedPropertyDescriptor`替代默认的`PropertyDescriptor`: ```csharp public class ...
首先,`PropertyGrid`控件本身并不直接支持自定义的编辑器,但它允许我们通过实现`ITypeDescriptorContext`、`ICustomTypeDescriptor`和`PropertyDescriptor`接口来自定义属性的显示和编辑方式。这些接口帮助我们...
// getters and setters } ``` 接着,我们需要一个`PropertyEditor`来处理`Gender`属性,因为它是枚举类型: ```java public class GenderEditor extends PropertyEditorSupport { @Override public void ...
自定义`PropertyDescriptor`类可以扩展标准的属性行为,例如改变其显示名称、添加属性标签或使用自定义编辑器。我们需要重写`PropertyDescriptor`的`GetEditor`、`GetValue`和`SetValue`方法。 4. **使用Attribute...
PropertyDescriptor pd = new PropertyDescriptor("dependency", exampleBean.getClass()); Method writeMethod = pd.getWriteMethod(); writeMethod.invoke(exampleBean, dependencyBean); ``` 此外,还可以实现一...
为了使属性浏览器支持子属性的独立编辑,我们需要实现`PropertyDescriptor`的两个方法:`GetPropertiesSupported`和`GetProperties`。`GetPropertiesSupported`返回`true`表示该属性支持子属性的编辑,而`...
PropertyDescriptor pd = new PropertyDescriptor(propertyName, clazz); Method mt = pd.getWriteMethod(); Type t [] = ms[i].getParameterTypes(); Object [] params = new Object[t.length]; for(int j...
在由JDK提供的默认的API中,有java.beans包,里面有诸如Introspector,BeanInfo,PropertyDescriptor等用来操作JavaBean的方法, 但是由Apache公司开发的BeanUtils会更常用,同时,BeanUtils还需要配合第三方日志...
PropertyDescriptor propDesc = new PropertyDescriptor("userName", UserInfo.class); Method methodSetUserName = propDesc.getWriteMethod(); methodSetUserName.invoke(userInfo, "wong"); ``` 这段代码首先...
`TypeDescriptor`是.NET框架中用于提供类型信息的类,而`PropertyDescriptor`则表示对象的一个属性,包括其名称、类型和可读写性等。通过重写这些类的方法,我们可以决定哪些属性应该在`PropertyGrid`中显示,哪些应...