Posts

Showing posts from November, 2007

Show all the System.Windows.Media.Colors using DataBinding

Image
Here is a sample to show all the Colors or even Brushes of WPF System.Windows.Media.Colors class. < ListBox ItemsSource = " {Binding Mode=OneWay, Source={StaticResource helper}} "   ItemTemplate = " {DynamicResource DataTemplate1} " /> Bellow is a function which gives all of its properties as PropertyInfo Collection.(If anybody out here knows a way to eliminate the use of this Helper class, please point that here) public class Helper {     public PropertyInfo[] GetPropNames( Type type)     {         return type.GetProperties();     } } Now you can write an ObjectDataProvider in XAML to call this function and then a DataTemplate to bind the PropertyName to the approapriate Dependancy Property. See the XAML   < Window.Resources >     < ObjectDataProvider x:Key = " helper " MethodName = " GetPropNames " ObjectType = " {x:Type local:Helper} " >       < ObjectDataProvider.MethodParameters >         < x:Typ