Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight /WPF: DependencyProperty.AddOwner & Render on change
    primarykey
    data
    text
    <p>I need to implement a Ruler and I have a CustomControl RangeSlider which is derived from Control and has several DependencyProperties (e.g. Minimum, Maximum, LowerValue, UpperValue).</p> <pre><code>public static readonly DependencyProperty LowerValueProperty = DependencyProperty.Register("LowerValue", typeof(double), typeof(RangeSlider), new FrameworkPropertyMetadata(0d, OnLowerValueChanged, CoerceLowerValue)); public double LowerValue { get { return (double)base.GetValue(LowerValueProperty); } set { base.SetValue(LowerValueProperty, value); } } </code></pre> <p>In Xaml, the Ruler has a sub control Scale (derived from Canvas), which needs the same Properties to draw the Scaling. If LowerValue or UpperValue changed, the Scale should repaint. So I add </p> <pre><code>public static readonly DependencyProperty LowerValueProperty = RangeSlider.LowerValueProperty.AddOwner(typeof(Scale), new FrameworkPropertyMetadata(1d)); </code></pre> <p>When I move the thumb, something should raised in Scale. First I implemented OnRender(DrawingContext) and added to the LowerValueProperty in RangeSlider FrameworkPropertyMetadataOptions. But it doesn't matter, nothing happens. Moreover I do not want to use OnRender(DrawingContext), because it's not available in Silverlight.</p> <p>Furthermore I wonder why the OnLowerValueChanged-Method in RangeSlider is raised but not the setter of LowerValue (at least the debugger does not break in there).</p> <p>So, is there a way for Silverlight &amp; WPF to raise a method automatically in Scale, when LowerValue in RangeSlider changed (except raising from OnLowerValueChanged)?</p> <p>Note: The above code is the WPF-Code. In Silverlight there are of course some difference, because Silverlight does not support among other things Coercion.<br> Because the code should run in Silverlight and WPF, I do not want to use OnRender(DrawingContext).</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.
    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