index > Windows Presentation Foundation ("Avalon") > How to get DependencyProperty by its name?

How to get DependencyProperty by its name?

Hello,

Could anyone suggest a way of getting a DependencyProperty object for some UIElement? I.e. I have a Button (button1) and I would like to do something like:

DependencyProperty dp = DependencyPropertyHelper.GetProperty(button1, "Content");

Thanks in advance

Edmundas

Edmundas

You can use reflection.

DependencyProperty dp =(DependencyProperty) typeof(Button).GetField("ContentProperty").GetValue(button1);




What's in your toolbelt? http://www.codeplex.com/Wiki/View.aspx?ProjectName=wpftoolbelt
ivolved_Mike_Brown

Thanks, this is it.

Edmundas

p.s. sometimes it is useful to think a little bit "out of the box" :)

Edmundas
reply 3

You can use google to search for other answers

 

More Articles

• Property trigger ExitActions
• Custom extentions
• Animating a camera
• What's equivalent in WPF for "Application.Restart()" in...
• WindowsFormsHost and AllowsTransparency="True" conflict...
• stupid question: how to use the "combo box" control
• MediaElement is playing HD-movies slow in RC1
• RC1 Presentation*.dll trouble with VS 2005
• dev setup for Vista RC2?
• Newbie question about WPF
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Fontsize relative to the window size
• Help needed in designing UI using CAB
• What is "best practise" for da
• What's equivalent in WPF for "Appli
• What facilities does WPF have for restri
• Trigger Error
• How to create the popup canvas when a pa
• HostingWpfUserControlInWf example crashes
• how to save content of document viewer w
• How to use btn.RaiseEvent to fire button
• PageFunction Base Class
• Data Binding: How to bind a group of Rad
• Adorner quirk
• Loose XAML Template
• custom control problems

Hot Articles

• How do we display Items in table format
• DoubleClick on FrameworkElement
• GroupStyle and WrapPanel
• Animating a camera
• Session ID equivalent in XBAP
• I am not able to install Orcas Technolog
• How to modify default WPF application st
• A form with a 1000 text boxes, help requ
• error when hosting WPF control inside of
• Reading or Converting other document typ
• load xaml dynamically in to a parent obj
• How to bind a Canvas's TranslateTransfor
• Creating graphs using WPF
• WPF download links
• Disable repaint

Recommend Articles

• How is WPF/E?
• Is it possible to drag objects in a WPF
• Anyway to change WindowsFormsHost z-orde
• WindowsFormsHost and AllowsTransparency=
• Memory Leak problem when using bitmap im
• ObservableCollection for IList
• New Window and STA problem....
• Finding Height of a chid control in a cu
• export to image with black block
• Skyboxes in WPF
• How can I move and resize window without
• WPF "Bugs" or "Features&q
• Creating a board game
• WPF Text blurry
• Multiple background images