Click here to Skip to main content
16,006,768 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Properly display dynamic calculations in databinding? [modified] Pin
artwallacex30-Apr-08 12:54
artwallacex30-Apr-08 12:54 
GeneralRe: Properly display dynamic calculations in databinding? Pin
User 27100930-Apr-08 15:07
User 27100930-Apr-08 15:07 
GeneralRe: Properly display dynamic calculations in databinding? Pin
artwallacex30-Apr-08 15:21
artwallacex30-Apr-08 15:21 
GeneralRe: Properly display dynamic calculations in databinding? Pin
User 27100930-Apr-08 15:37
User 27100930-Apr-08 15:37 
GeneralRe: Properly display dynamic calculations in databinding? Pin
artwallacex30-Apr-08 15:53
artwallacex30-Apr-08 15:53 
GeneralRe: Properly display dynamic calculations in databinding? Pin
User 27100930-Apr-08 16:01
User 27100930-Apr-08 16:01 
GeneralRe: Properly display dynamic calculations in databinding? Pin
artwallacex30-Apr-08 16:26
artwallacex30-Apr-08 16:26 
GeneralRe: Properly display dynamic calculations in databinding? Pin
Ed.Poore3-May-08 0:08
Ed.Poore3-May-08 0:08 
artwallacex wrote:
Are there any solutions to just hardcoding a bunch of these NotifyPropertyChanged in every editable field?

Since you're using WPF then you'll be using C# 2.0 at least so you could do something like this (just made up an example since I haven't downloaded your files):
private TimeSpan _TimeCode;
private TimeSpan _TimeCodeCalc;

public TimeSpan TimeCode
{
	get { return _TimeCode; }
	set
	{
		_TimeCode = value;
		TimeCodeCalc = new TimeSpan(value.TotalMinutes);	// Change another "readonly" property
		NotifyPropertyChanged("TimeCode");
	}
}
public TimeSpan TimeCodeCalc
{
	get { return _TimeCodeCalc; }
	private set
	{
		_TimeCodeCalc = value;
		NotifyPropertyChanged("TimeCodeCalc");
	}
}
You'll notice the private modifier on the TimeCodeCalc property, what this does is that only your class will be able to change the value.  If you wrap your readonly properties like this then at least when you modify them you only have to set the wrapper property and the PropertyChanged event will be fired off.  That way you don't have to remember to fire notify about every property in every place where you set it.  Just use the new private set method rather than the field to modify the value.

[edit]
I've had a look at your simple solution and modified it to give you an example: http://www.pooredesign.com/downloads/wpf-databinding-calcupdate.zip[^]
[/edit]



GeneralRe: Properly display dynamic calculations in databinding? [modified] Pin
artwallacex1-May-08 10:51
artwallacex1-May-08 10:51 
GeneralRe: Properly display dynamic calculations in databinding? Pin
User 2710092-May-08 15:18
User 2710092-May-08 15:18 
QuestionPlease help me in wpf/expression blend Pin
kishorekumar.malla@live.com30-Apr-08 0:07
kishorekumar.malla@live.com30-Apr-08 0:07 
AnswerRe: Please help me in wpf/expression blend Pin
User 171649230-Apr-08 0:43
professionalUser 171649230-Apr-08 0:43 
AnswerRe: Please help me in wpf/expression blend Pin
Pete O'Hanlon30-Apr-08 1:37
mvePete O'Hanlon30-Apr-08 1:37 
AnswerRe: Please help me in wpf/expression blend Pin
User 27100930-Apr-08 3:04
User 27100930-Apr-08 3:04 
GeneralRe: Please help me in wpf/expression blend Pin
Pete O'Hanlon30-Apr-08 3:21
mvePete O'Hanlon30-Apr-08 3:21 
GeneralRe: Please help me in wpf/expression blend Pin
User 171649230-Apr-08 10:38
professionalUser 171649230-Apr-08 10:38 
GeneralRe: Please help me in wpf/expression blend Pin
Pete O'Hanlon30-Apr-08 11:13
mvePete O'Hanlon30-Apr-08 11:13 
GeneralRe: Please help me in wpf/expression blend Pin
User 27100930-Apr-08 15:04
User 27100930-Apr-08 15:04 
GeneralRe: Please help me in wpf/expression blend Pin
Pete O'Hanlon30-Apr-08 23:14
mvePete O'Hanlon30-Apr-08 23:14 
GeneralRe: Please help me in wpf/expression blend Pin
User 17164921-May-08 0:35
professionalUser 17164921-May-08 0:35 
GeneralRe: Please help me in wpf/expression blend Pin
Pete O'Hanlon1-May-08 1:01
mvePete O'Hanlon1-May-08 1:01 
GeneralRe: Please help me in wpf/expression blend Pin
User 17164921-May-08 1:09
professionalUser 17164921-May-08 1:09 
GeneralRe: Please help me in wpf/expression blend Pin
Jammer2-May-08 4:32
Jammer2-May-08 4:32 
QuestionText Ticker Pin
KBou28-Apr-08 2:07
KBou28-Apr-08 2:07 
GeneralRe: Text Ticker Pin
User 27100928-Apr-08 3:35
User 27100928-Apr-08 3:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.