Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How to bind code to a DependencyProperty?

$
0
0

We have a UserControl that defines a dependency property. How can code behind subscribe to changes in this property?

Property defined like this:

public partial class DateRangeSlider : UserControl
{<snipped for brevity>
. . . .
public DateTime LowerValue
{
    get { return (DateTime)GetValue(LowerValueProperty); }
    set { SetValue(LowerValueProperty, value); }
}

public static readonly DependencyProperty LowerValueProperty =
 DependencyProperty.Register("LowerValue", typeof(DateTime), typeof(DateRangeSlider), new UIPropertyMetadata(DateTime.Now.AddDays(-7)));

. . . 
}
The idea is to have change notifications from this UserControl broadcast back to the window Controller code (NOT the XAML) but I'm not sure how to wire this up. Any suggestions would be greatly appreciated.


Richard Lewis Haggard


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>