Is it possible to know when Content of a Plotter.Children has changed?

Aug 24, 2009 at 5:43 PM

Say I have a Header whos content is just text (GetGraphTitle returns a string):

 

Header thisHeader = new Header()
{
   Content = GetGraphTitle(),
};

Is there any way/Event to know when the Content has changed?

 

Editor
Aug 24, 2009 at 7:27 PM

Hi,

This question seems a little bit strange to me - first of all, in header of topic you are mentioning Plotter.Children, but in body of your question there are no words about it. 

So I'll answer at all possible questions, that might be in your mind when you we asking it:

1) plotter.Children has a CollectionChanged event, which is raise when smth is added or removed in or to plotter.Children.

2) As Header is a simple ancestor of WPF's ContentControl, so Content property is a ContentControl.Content DependencyProperty. We can or cannot be notified about its change only if or if not developers of WPF's ContentControl created necessary means. They don't. But don't be sad - there is a workaround of it:

 

DependencyPropertyDescriptor descr = DependencyPropertyDescriptor.FromProperty(ContentControl.ContentProperty, typeof(ContentControl));
descr.AddValueChanged(actualHeaderInstance, your_event_handler);

This is a general way to be notified about change of every DependencyProperty.

3) Why do you need to be notified when the Content property has changed? You are setting it from your code, so every place in your code where you are changing its value can be a source of event. You might be in need of such an event if you are using Binding or smth like that.

 

Have I answered on your question?

Mikhail.

 

Sep 1, 2009 at 12:19 PM

Hi Mikhail,

 

Sorry for the disambiguity in the original question.

 

What I was looking for was a way to know when the content of say the Header or an Axis Title had changed from the GUI.

My Axis Titles and Header Content are always Text - so if a user right clicks on one, I create an adorner layer text box to recieve new input. The DependencypropertyDescriptor works as you described above. Thank you very much.

 

John