2. Mahender Sarangam Having 5 years of experience on .NET Technologies. Working as a Senior Software Engineer in United Health Group (UHG India Information Service Ltd.). Worked with Big Firms like Deloitte Consulting & Wipro Technology. Got Technical Acquaintance on Technologies like C#, ASP.NET,AJAX, LINQ, Silverlight, WPF,WCF ,SQL Server, Team Foundation Server(TFS) and SharePoint Technology. MCTS Certified in Web Technologies. Blog : http://Msarangam.wordpress.com
3. Attached Property Attached property is kind of Dependency property defined in XAML. For example, Canvas. Left is an attached property defined by the Canvas type , Storyboard.TargetProperty Interesting feature about Attached property is that they are not defined in the type they are declared but you can use them in another different class hierarchy “The attached properties are intended to be used as global properties that are settable on any type of object” - Microsoft Definition
4. The Main advantage of Attached property is to allow different child elements to specify unique values for a property that is actually defined in a parent element. Registering and using custom attached properties in Silverlight Attached Property can only created if the class inherit from Dependency objects. Why we need attached properties? Because of dynamic extension of classes without inheritance Location of Property are stored, where there are defined, Use the property when you need and what you need it. The attached property reports information to a service.
5. Code Snippet publicstaticreadonlyDependencyPropertyTabStopProperty = DependencyProperty.RegisterAttached( "TabStop", //Name of the property typeof( bool ), //Type of the property typeof( TabPanel ), // Type of the provider of the registered attached property null ); //Callback invoked in case the property value has changed publicstaticvoidSetMyProperty( DependencyObjectobj, stringpropertyValue ) { obj.SetValue( MyPropertyProperty, propertyValue ); } publicstaticstringGetMyProperty( DependencyObjectobj ) { return ( string )obj.GetValue( MyPropertyProperty ); }
6. The value of every attached property is stored in the class the property is being attached to. For example if you define value for the TabStop property of a button then this value is stored internally in the button, not in the TabPanel that registered it. Canvas.Top – Define the distance for a control from the top edge of its container;Canvas.Left – Define the distance for a control from the left edge of its container;Canvas.ZIndex – Z Index of the control;Grid.Row – Define the row index for a control placed in a Grid container;Grid.Column – Define the row index for a control placed in a Grid container;ScrollViewer.HorizontalScrollBarVisibility – Define the visibility of the horizontal scrollbar;ScrollViewer.VerticalScrollBarVisibility – Define the visibility of the vertical scrollbar;ToolTipService.ToolTip – Define the tool tip associated with a control;