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 677067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:59:53+00:00 2026-05-14T00:59:53+00:00

I have a user control let say UC1 . This user control have viewmodel

  • 0

I have a user control let say UC1 . This user control have viewmodel UC1_vm.

In the usercontrol UC1 I have a canvas in which drawing curve logic is implemented. This drawing curve logic is based on the data points property in the view model ( UC1_vm).

The data points property inside the view model change with different condition. The generation of data points is written in the View Model.

I want to bind the data points property in the view model to the draw curve logic inside the User control (view). I want whenever the data point property is changed in the view model , the canvas calls the draw curve method.

Can I set the set any property of canvas which when changed it calls the on paint logic auto matically?

Please suggest me the approach of implementing this scenario!!

  • 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-05-14T00:59:53+00:00Added an answer on May 14, 2026 at 12:59 am

    It sounds like you have a DependencyProperty that is the collection of points in your UserControl. When you register it, use the FrameworkPropertyMetadata metadata, and specify the FrameworkPropertyMetadataOptions.AffectsRender in the metadata constructor. Note that this will only work if the entire collection is replaced (if you raise PropertyChanged for the collection, but the collection instance hasn’t changed, your paint still won’t get called).

    If your collection implements INotifyCollectionChanged, then you can wire up a collection changed event handler that invalidates the visual:

    public static DependencyProperty PointsProperty = DependencyProperty.Register(
        "Points",
        typeof(IEnumerable<Point>),
        typeof(UC1),
        new FrameworkPropertyMetadata(null, 
            FrameworkPropertyMetadataOptions.AffectsRender,
            OnPointsChanged));
    
    public IEnumerable<Point> Points
    {
        get { return (IEnumerable<Point>)GetValue(PointsProperty); }
        set { SetValue(PointsProperty, value); }
    }
    
    private static void OnPointsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        UC1 ctrl = d as UC1;
        if (e.NewValue != null && e.NewValue is INotifyCollectionChanged)
            ((INotifyCollectionChanged)e.NewValue).CollectionChanged += ctrl.PointsChanged;
    
        if (e.OldValue != null && e.OldValue is INotifyCollectionChanged)
            ((INotifyCollectionChanged)e.OldValue).CollectionChanged -= ctrl.PointsChanged;
    }
    
    private void PointsChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        InvalidateVisual();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a User Control, let's say TextboxPage and it's associated with ViewModel, TextboxPageViewModel.
I have a user control which I use as a listboxItem. On this user
Let's say I have an a .ascx user control. How do I get its
This is basically implementing search/find in a WPF window or User control. Let's say
I have several user controls, let's say A , B , C and D
Let's pretend I have the following xaml... <UserControl.Resources> <local:ViewModel x:Name=viewModel /> <local:LoadChildrenValueConverter x:Name=valueConverter />
I have user control named DateTimeUC which has two textboxes on its markup: <asp:TextBox
i have user control, which i render on several views. i want to show
Can EF really be this bad? Maybe... Let's say I have a fully loaded,
I have a control on a page (let's say a button). I want to

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.