思路:通过视图控制器 访问到 按钮所属的控制器,给Action设置TargetObjectsCriteria表达式。
以下代码设置框架内置的删除按钮符合一定条件才可用。不符合条件时,按钮处于禁用状态(灰色)。
protected override void OnActivated() { base.OnActivated(); // Perform various tasks depending on the target View. Frame.GetController<DeleteObjectsViewController>().DeleteAction.TargetObjectsCriteria = CriteriaOperator.Parse("xx = ?", "").LegacyToString(); } protected override void OnDeactivated() { // Unsubscribe from previously subscribed events and release other references and resources. base.OnDeactivated(); Frame.GetController<DeleteObjectsViewController>().DeleteAction.TargetObjectsCriteria = string.Empty; }