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
6
votes
2 answers

Get parent for GridViewColumn

Is there a way to get the parent (ListView) for a GridViewColumn? I have tried with LogicalTreeHelper and VisualTreeHelper but no dice. I can share a what-have-you-tried that is a bit funny, it works but ugly is not close to describing it: public…
Johan Larsson
  • 17,112
  • 9
  • 74
  • 88
6
votes
2 answers

How do dependency/attached properties work internally and where are values stored?

I'm a little bit unclear with all this magic. As I understood dependency properties get inherited from the DependencyObject, so values are stored: in the instance itself if value is assigned (in the local dictionary) or taken from the link to a…
elm
  • 339
  • 5
  • 12
6
votes
2 answers

Where to put the XML documentation comments for an attached property?

Assuming I have an attached property defined like that : public static string GetMyProperty(DependencyObject obj) { return (string)obj.GetValue(MyPropertyProperty); } public static void SetMyProperty(DependencyObject obj,…
Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
5
votes
2 answers

"The attachable property not found in type " error while using a dependency property in Silverlight

I am trying to do some sample applications to use Dependency Property in a DataGrid,but when i tried to run application I am getting an run time exception The attachable property 'SelectedColumnIndex' was not found in type …
5
votes
1 answer

Binding an attached property to an item in ItemsControl with custom panel problem

I can't get the following XAML to work as I want. All bindings work because get no errors from the bindings. But I don't get the expected result from the binding on the RatioShape rectangle. The problem is that the attached property…
Stefan Ahlm
  • 268
  • 4
  • 11
5
votes
1 answer

SortDescription with custom attached property

In Xaml I can set a custom attached property using local:TestClass.TestProperty="1" An I can bind to a custom attached property using {Binding Path=(Namespace:[OwnerType].[PropertyName])} {Binding Path=(local:TestClass.TestProperty)} But how do I…
Krimson
  • 762
  • 6
  • 25
5
votes
1 answer

Template Binding for Custom Attached Property

I am trying to use an Image in Button Control which animates on Hover and Pressed state by showing different images. Accordingly, I have defined 3 attached properties for the Button Control as given below. public class ButtonExtensions :…
Jatin
  • 4,023
  • 10
  • 60
  • 107
5
votes
5 answers

Silverlight 4 Default Button Service

For a few months I have been successfully using David Justices Default Button example in my SL 3 app. This approach is based on an attached property. After upgrading to SL4, the approach no longer works, and I get a XAML exception: Unknown parser…
Mark Cooper
  • 6,738
  • 5
  • 54
  • 92
5
votes
1 answer

How to set an attached property programmatically eg. Viewport2DVisual3D.IsVisualHostMaterialProperty

I'd like to know how to programmatically set the WPF Dependecy Property Viewport2DVisual3D.IsVisualHostMaterialProperty . In the xaml I would use:
Marco
  • 1,454
  • 1
  • 16
  • 30
5
votes
1 answer

How to use the Child-Defined Attached Properties?

1. Issue As we know,Attached Property widely expands the property system in wpf.But all the examples which are familiar to us are almost Parent-Defined ones,such as DockPanel.Dock / Grid.Row and so on.But after checking the document in MSDN,I found…
Claw
  • 474
  • 5
  • 16
5
votes
3 answers

Can't set Storyboard.TargetProperty to CompositeTransform.Rotation in Metro style app from code

I'm messing around with some Storyboards in a Metro XAML app. I have to create a Storyboard in code. I'd like to set the Storyboard.TargetProperty to CompositeTransform.Rotation It seems impossible... My Storyboard in XAML looks like…
Tenshiko
  • 1,450
  • 3
  • 17
  • 33
4
votes
2 answers

Attached Event? How to remove ScrollChanged event handler for WPF DataGrid at runtime

The WPF DataGrid class (Not the Windows Forms DataGrid!) can be set up to automatically handle scrolling without an external ScrollViewer and it's possible to register an event handler for the control's internal scrollbar by writing XAML like…
ivanatpr
  • 1,862
  • 14
  • 18
4
votes
2 answers

Attached Properties

I am a little confused about WPF attached properties. When you use an attached property that attached property can only be read and used by the class that defines it correct? For example if I wanted to use some attached property as a hover color on…
mihajlv
  • 2,275
  • 4
  • 36
  • 59
4
votes
2 answers

Binding within an AttachedProperty of Type Collection to an other Element

I want to create an AttachedProperty of Type Collection, which contains references to other existing elements, as shown below:
0xbadf00d
  • 17,405
  • 15
  • 67
  • 107
4
votes
2 answers

How can a WPF Canvas child's attached top/bottom/left/right property be removed?

Perhaps I am missing something simple here, but I am unable to find a method to remove an attached property from a item contained by a canvas. Code example: //Add an image to a canvas; set the location to the…
Robert Altman
  • 5,355
  • 5
  • 33
  • 51
1 2
3
30 31