Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7785501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:15:58+00:00 2026-06-01T20:15:58+00:00

I created a control, derived from Canvas , that should plot a live diagram,

  • 0

I created a control, derived from Canvas, that should plot a live diagram, given values that are passed via a binding to a DependencyProperty. The simplified version is this:

public class Plotter : Canvas
{
    public float Value { get { return (float)GetValue(ValueProperty); } set { SetValue(ValueProperty, value); } }

    public static readonly DependencyProperty ValueProperty =
        DependencyProperty.Register("Value", typeof(float), typeof(Plotter),
        new PropertyMetadata(0f, new PropertyChangedCallback(ValueChangedCallBack)));

    public static void ValueChangedCallBack(DependencyObject property, DependencyPropertyChangedEventArgs args)
    {
        Plotter plotter = (Plotter)property;
        plotter.Value = (float)args.NewValue; //<-- Removed this line to get it to work

        // Actually draw the value into the canvas geometry
        plotter.PlotValue(plotter.Value);
    }
}

I bound the control like this:

<mystuff:Plotter Value="{Binding MyViewModelProperty}" Height="50" Width="200" />

My ViewModel implements INotifyPropertyChanged and calls PropertyChanged correctly. If I bind MyViewModelProperty to a textbox, it correctly updates every time. Only if I bind it to my own control, my ValueChangedCallBack is only called once as the page is loaded, and then never again.

What am I not seeing here? Thanks for any help!

Solved: I dont have to set the Value explicitly in the callback.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:15:59+00:00Added an answer on June 1, 2026 at 8:15 pm

    You set the property Value on the callback for the property Value changing. That doesn’t make much sense in any case. But is that locally set value overriding the binding value, causing your binding to no longer be set on the dependency property?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a new UIElement that derives from Systen.Windows.Controls.Canvas. I am trying to
I have a customized WPF control that is derived from UserControl. In the Resources
I want to create a control (derived from TCustomControl) that is invisible but reacts
I've created a CloseableTabItem control that derives from TabItem . Now I'd like to
I'd like to create a derived control from System.Windows.Forms.ComboBox that is bound to a
I've created a control derived from ComboBox, and wish to unit test its behaviour.
I've created an MFC control class, which I derived from CWnd. The control is
I'm creating a custom control derived from UserControl that I would like to set
I created an asp.net Server control that derives from a LinkButton, and renders a
I've created a control that extends the BoundField control to do some special processing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.