0

Having a view inherited from Catel's DataWindow base class with DataWindowMode.OkCancelApply. Now I am trying to disable OK/Apply (or even only Apply) buttons and enable them when some model's property has been modified.

After investigation, I found that ValidateData() override does what I need. Still can't figure out how to validate unchanged properties from the model there by using Catel.

crthompson
  • 15,653
  • 6
  • 58
  • 80
IUnknown
  • 335
  • 1
  • 11

1 Answers1

0

Catel supports different ways of validation:

  1. On the model (but then you will need ViewModelToModel or Expose attributes)
  2. On the view model (override ValidateFields and ValidateBusinessRules)

For more information about validation in Catel, see this documentation:

Geert van Horrik
  • 5,689
  • 1
  • 18
  • 32
  • thanks Geert! I've checked those pages as well. For my purpose it is required to track IsDirty status of the model. If it is set to true then Apply button in the View must be enabled, otherwise disabled. – IUnknown Dec 03 '13 at 17:28
  • Ah, I don't think there is a real solution for that. Why can't you just keep it enabled all the time? – Geert van Horrik Dec 03 '13 at 18:06
  • I wish I could but there is according to the app requirements. The simplest theoretical way to implement that is to override `ValidateData()` and just return underlying model's `IsDirty` value. Practically that is not easy because: 1. View can't access Model, 2) In case i get the model with the help of `ServiceLocator`, its `IsDirty` for some reason is always `true` – IUnknown Dec 03 '13 at 18:12
  • For now, I don't see any reason to implement that. But you can always put it on the backlog. – Geert van Horrik Dec 03 '13 at 19:41