Note that there are some explanatory texts on larger screens.

plurals
  1. PODependency Property Binding Not Updating Target
    primarykey
    data
    text
    <p>I have a custom dependency property:</p> <pre><code> public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register("HeaderProperty", typeof(string), typeof(RadAdjustableSlider)); public string Header { get { return (string)GetValue(HeaderProperty); } set { SetValue(HeaderProperty, value); } } </code></pre> <p>I then have a binding in my xaml:</p> <pre><code>&lt;TextBlock Name="txtHeader" Text="{Binding ElementName=main, Path=Header, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" /&gt; </code></pre> <p>Note that I also have this in the declaration at the top of the xaml file:</p> <pre><code> x:Name="main" </code></pre> <p>Finally, I have this constructor:</p> <pre><code> public RadAdjustableSlider() { InitializeComponent(); this.Header = "Header"; } </code></pre> <p>When I put this control inside of another parent control, the Header textblock is blank. Why?</p> <p>Edit: <a href="http://geekswithblogs.net/thibbard/archive/2008/04/22/wpf-custom-control-dependency-property-gotcha.aspx" rel="nofollow noreferrer">This blog</a> says that the correct way to do this is by providing a <a href="http://msdn.microsoft.com/en-us/library/system.windows.validatevaluecallback.aspx" rel="nofollow noreferrer">ValidateValueCallback</a> in the <code>DependencyProperty.Register</code> call, but that seems like quite a bit of plumbing and doesn't explain the way dependency properties behave when interacting with external controls. Am I really going to have to write callback functions for all of my dependency properties?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload