This project is read-only.
Although the following paragraph doesn't describe a new feature of the PDFx, it demonstrates a use case that solves a common problem developers face every day, apart from the sole monitoring of large Property Dependency networks.

One Way Converters

The source code of the following example can be found in ViewModel ConverterDemonstrationVM which is part of the WPFSample's source code.

In Two Way Converters I argue that value converters should be used exclusively to convert business domain data to UI specific data rather than to solely transform business domain data. I also showed how the PDFx can be employed to render two-way value converters, which convert domain data, redundant. The very same pattern can be applied to mimic the behavior of one way value converters in your ViewModel:

class ViewModel : BindableExt
{
	private Model Model { get; set; }

	public string MoneyQuantification
	{
		get
		{
			Property(() => MoneyQuantification)
				.Depends(p => p.On(Model, k => k.MoneyInEuros));

			if (Model.MoneyInEuros < 0)
			{
				return "Not too much";
			}

			if (Model.MoneyInEuros < 1000)
			{
				return "A Little";
			}

			if (Model.MoneyInEuros < 10000)
			{
				return "Quite some";
			}

			return "A Lot";
		}
	}
}

class Model : BindableExt
{
	private double _moneyInEuros = 100;
	public double MoneyInEuros
	{
		get { return _moneyInEuros; }
		set
		{
			_moneyInEuros = value;
			NotifyPropertyChanged(() => MoneyInEuros);
		}
	}
}

In this scenario, the PDFx ensures that the MoneyQuantification Property gets reevaluated whenever the Model's MoneyInEuros Property changes.

Last edited May 14, 2013 at 6:30 PM by KevinStumpf, version 3

Comments

No comments yet.