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

  • Home
  • SEARCH
  • 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 9297339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:03:06+00:00 2026-06-18T22:03:06+00:00

I have an Objectmodel with some nested Collections: public class MainViewModel : BaseViewModel {

  • 0

I have an Objectmodel with some nested Collections:

public class MainViewModel :  BaseViewModel
{
    private Dictionary<String, Diagram> _diagrams;

    public Dictionary<String, Diagram> Diagrams
    {
        get { return _diagrams; }
        set
        {
            _diagrams = value;
            OnPropertyChanged("Diagrams");
        }
    }

}

Base Viewmodel implements INotifyPropertyChanged. Inside Diagram there is a Collection of Curves:

public class Diagram
{
    private  ObservableCollection<DiagramCurve> curves;
    [JsonIgnoreAttribute]
    public ObservableCollection<DiagramCurve> Curves
    {
        get { return curves; }
    }

    public Diagram()
    {
        curves = new ObservableCollection<DiagramCurve>();
    }
}

I bind to an instance of DiagramCanvas in my Xaml like this:

    <wd:DiagramCanvas x:Name="diagramCanvas" 
                          Diagram ="{Binding Diagrams[Diagram1]}"  
                          Grid.Row="2" Grid.Column="1" 
                          Height="auto" Width="Auto"  
                          HorizontalAlignment="Stretch"  
                          VerticalAlignment="Stretch" 
                          Margin="10"   
                          Background="{StaticResource DiagrambackgroundBrush }" />

which works fine if I assign the the Diagrams property of MainView a completely new Diagrams collection. But what I need is that the DiagramCanvas Control get’s updated when the Curves Collection changes. But this does not happen.

  • 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-18T22:03:07+00:00Added an answer on June 18, 2026 at 10:03 pm

    I tried to inherit Diagram from an ‘ObservableCollection’, but even this didn’t help as in ObservableCollection dependency property does not update when item in collection is deleted explained.

    As the DependencyProperty of my CustomControl DiagramCanvas binds to a value item of the Dictionary MainViewModel.Diagrams not to a property of a Diagram instance, no OnPropertyChanged event of the DependencyProperty of DiagramCanvasis fired, when properties of the Diagram instance change.

    Only when a new value is assigned to the value item inside the Dictionary MainViewModel.Diagrams, this event gets fired, beacause this assigns a new value to the DependencyProperty of DiagramCanvas.

    Therefore I have to subscribe to the events of the collection manually:.

    public class DiagramCanvas : Canvas
    {
      // Is called only when new Items get inserted info the Dictionary
      static void OnDiagramPropertyChanged(DependencyObject obj, 
                                         DependencyPropertyChangedEventArgs args)
      {
          DiagramCanvas THIS = (DiagramCanvas)obj;
    
          Diagram new_diagram = (Diagram)args.NewValue;
          Diagram old_diagram = (Diagram)args.NewValue;
    
          if (old_diagram != null)
          {
            // Unsubscribe from CollectionChanged on the old collection
            old_diagram.Curves.CollectionChanged -= THIS.OnCollectionChanged;
          }
    
          if (new_diagram != null)
          {
            // Subscribe to CollectionChanged on the new collection
            new_diagram.Curves.CollectionChanged += THIS.OnCollectionChanged;
          }
      }
    
      //Is called everytime the Curves collecion changes
      void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
      {
    
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys i have collection : public class ActionData { private int iD; public
I have the following class :- class A { public: // some stuff that
I have an object model that looks like this: public class MyModel { public
I have extended a class like so: public class CormantRadDock : Telerik.Web.UI.RadDock { public
I am in a small fix, I have a class as below. Public Class
Let us have the followig class class Animal { public: virtual short getFeet() =
I have an object model like this: public class MyClass { int TheProp {get;set;}
I have some functions that process the parameter, like : def createDataModel(objectModel): ...... def
have written this little class, which generates a UUID every time an object of
I have a modeled a set of objects that correspond with some real world

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.