C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
iOS
Java
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
6
Reply
What is Dependency property in WPF?
harvendra singh
11y
3.6k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
https://msdn.microsoft.com/en-us/library/aa581779.aspx
Ajay Gandhi
10y
0
Dependency properties are properties which provide a way to compute the value of a property based on the value of other inputs.
Ajay Gandhi
10y
0
Dependency Properties Overview. Windows Presentation Foundation (WPF) provides a set of services that can be used to extend the functionality of a common language runtime (CLR) property.
Kml Surani
10y
0
http://www.c-sharpcorner.com/UploadFile/6d590d/wpf-dependency-property/
Munesh Sharma
11y
0
DependencyProperty are the properties which can be used in another control,Ex: i have a rectangle, Canvas.Right='100' Canvas.Left='200'here Canvas is the another contol,so we can use it in the rectangle
Sunil Gaded
11y
0
DependencyProperty :A dependency property is a property where the current value is dependent (hence the name) on other aspects such as default values, validation, coercion, value inheritance or animation. Also a depedency property has inbuilt support for change notifications, data binding and styling. The purpose of dependency properties is to provide a way to compute the value of a property based on the value of other inputs. These other inputs might include system properties such as themes and user preference, just-in-time property determination mechanisms such as data binding and animations/storyboards, multiple-use templates such as resources and styles, or values known through parent-child relationships with other elements in the element tree. In addition, a dependency property can be implemented to provide self-contained validation, default values, callbacks that monitor changes to other properties, and a system that can coerce property values based on potentially runtime information. Derived classes can also change some specific characteristics of an existing property by overriding dependency property metadata, rather than overriding the actual implementation of existing properties or creating new properties. How to create a DependencyProperty :To create a DependencyProperty, add a static field of type DepdencyProperty to your type and call DependencyProperty.Register() to create an instance of a dependency property. The name of the DependendyProperty must always end with ...Property. This is a naming convention in WPF. To make it accessable as a normal .NET property you need to add a property wrapper. This wrapper does nothing else than internally getting and setting the value by using the GetValue() and SetValue() Methods inherited from DependencyObject and passing the DependencyProperty as key. Important: Do not add any logic to these properties, because they are only called when you set the property from code. If you set the property from XAML the SetValue() method is called directly. If you are using Visual Studio, you can type propdp and hit 2x tab to create a dependency property.// Dependency Property public static readonly DependencyProperty CurrentTimeProperty = DependencyProperty.Register( "CurrentTime", typeof(DateTime),typeof(MyClockControl), new FrameworkPropertyMetadata(DateTime.Now));// .NET Property wrapper public DateTime CurrentTime {get { return (DateTime)GetValue(CurrentTimeProperty); }set { SetValue(CurrentTimeProperty, value); } }Each DependencyProperty provides callbacks for change notification, value coercion and validation. These callbacks are registered on the dependency property.
Rajendra Tripathy
11y
0
Message