Questions tagged [attached-properties]

In Windows Presentation Foundation (WPF), attached properties are a specialized form of dependency property that does not have the conventional property "wrapper".

An attached property is intended to be used as a type of global property that is settable on any object. It allows different child elements to specify unique values for a property that is actually defined in a parent element (Grid.Row and Grid.Column are an example of frequenly used attached dependency properties).

General information: Attached Properties Overview

458 questions
4
votes
2 answers

How to bind to attached property in XAML, WPF

I would like to bind the User.Password property to PasswordBox (TwoWay). Since PasswordBox.Password is not bindable, I made AttachedProperties to fix this (one to activate the binding, and one to hold the actual password). The problem is that they…
Tenshiko
  • 1,450
  • 3
  • 17
  • 33
4
votes
2 answers

Make attached properties work inside DataTemplate

I got an ItemsControl which uses a Canvas as ItemsPanel and its items are rendered to different WPF shapes depending on the bound type, basically like this:
ZoolWay
  • 5,411
  • 6
  • 42
  • 76
4
votes
2 answers

WPF attached properties not firing code behind when set in xaml

I have a custom ClockFace UserControl which has properties to allow colors, font and hands (as a Path objects) to be changed. This is used in custom TimePicker and Clock UserControls. In these parent controls, the ClockFace properties can be set on…
Sheridan
  • 68,826
  • 24
  • 143
  • 183
4
votes
2 answers

WPF: In an attached property, how to wait until visual tree loaded properly?

I have an Attached Property in a WPF app. The code below is inside the OnLoad event, but it doesn't work unless I add a hacky 500 millisecond delay in. Is there some way to avoid this delay, and detect when the visual tree has been loaded? private…
Contango
  • 76,540
  • 58
  • 260
  • 305
4
votes
5 answers

What are the various uses of Attached Properties?

I've seen some really varying uses of AttachedProperties so far in my adventures in WPF, and am wondering, what are some of the various uses? I've seen fairly mundane uses, such as those found in Grid and Canvas, as well as some really cool hacks…
Matt DeKrey
  • 11,582
  • 5
  • 54
  • 69
4
votes
1 answer

How are attached properties useful in LINQ?

I got this question during an interview in the past and never really dug into in, but I've put some thought into it lately and I can't come up with a good answer. When I think of attached properties my mind goes straight to UI related concepts -…
James Cadd
  • 12,136
  • 30
  • 85
  • 134
4
votes
2 answers

Deselecting text in ComboBox

I have a ComboBox with IsEditable is set to True so I'm able to type in the TextBox in the ComboBox. Now, I want the DropDownList to open so I created a Attached Property for it: Public Shared Function GetShowDropDown(obj As DependencyObject) As…
Krowi
  • 1,565
  • 3
  • 20
  • 40
4
votes
1 answer

Attached Property. How to use SetValue in PropertyChangedCallback

I need Attached Property that sets focus to UIElement from ViewModel. I've created Attached property and in PropertyChangedCallback I set focus to UIElement. private static void VoySetFocusChanged(DependencyObject o,…
tomatino
  • 108
  • 4
4
votes
1 answer

Attached Property Binding not working

I created an attached property to set commands using inputbinding on a datagridRow or datagricell in the style of the element. Here im trying to add inputBinding on thing that are dynamically created such as datagridrows/cells, this is why im trying…
4
votes
1 answer

Binding to attached property

I'm trying to bind from Button's ContentTemplate to attached property. I read all the answers for question similar to "binding to attached property" but I had no luck resolving the problem. Please note that example presented here is a dumbed down…
Milosz Krajewski
  • 1,160
  • 1
  • 12
  • 19
4
votes
2 answers

Get attached property value from content in contentpresenter

I've made a custom window that has a template defined in a resource dictionary. The window has no title bar.
Loetn
  • 3,832
  • 25
  • 41
4
votes
2 answers

Garbage Collection when Attached dependencyobject is destroyed \ disconnected

When we use any attached property against any dependency object, I thunk it actually maps the property and the value with the dependency object. E.g. Here value "Top" is…
WPF-it
  • 19,625
  • 8
  • 55
  • 71
4
votes
1 answer

wpf attached property: where to unsubscribe from event handling?

I have a dependency property (bool) which enables a behavior in a textbox. The property changed callback subscribes to some eventhandlers: static void MyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is…
deafjeff
  • 754
  • 7
  • 25
3
votes
1 answer

Attach property to usercontrol and updating it at design time

How can I create a user control like the Textbox? For example when I change the Text property of a Textbox control the new text appears on the window that I am currently working with. In my project I have a lot of places where the user has to enter…
Tono Nam
  • 34,064
  • 78
  • 298
  • 470
3
votes
2 answers

Bind TextBox.Text in Watermark attached property to localize it

I need to add Watermarks to my WPF application and I am using this watermark service to achieve it. It works just as expected, but I need to localize the text showed as watermark and I can't find a way to achieve it. My xaml declaration:
JoanComasFdz
  • 2,911
  • 5
  • 34
  • 50