【发布时间】:2013-08-23 13:41:10
【问题描述】:
我在 AppBar 上有一个按钮,当 ViewModel 中的属性变为 true 时,我已将其设置为启用。出于某种原因,仅在第一次显示 AppBar 时才检查 IsEnabled 绑定。我错过了什么吗?
这是我在视图中的按钮 XAML(为清楚起见,省略了 AppBar xaml):
<Button Style="{StaticResource DocumentAppBarButtonStyle}" AutomationProperties.Name="Approve"
Command="{Binding ApproveTimesheetCommand, Mode=OneWay}"
IsEnabled="{Binding IsAbleToProcessTimesheet, Mode=OneWay}" />
这是我在 ViewModel 中的属性:
public bool IsAbleToProcessTimesheet
{
get
{
return SelectedTimesheets.Count() > 0;
}
}
在属性上设置断点表明它仅在第一次显示 App Bar 时被调用。显示 App Bar 的后续调用不会触发对 IsEnabled 属性的检查。
您是否需要设置一些东西来让 XAML 在每次显示 AppBar 时调用该属性?
任何帮助将不胜感激。
【问题讨论】:
-
您必须通知某处的属性更改,以便刷新 UI。最好在同一个地方更改集合。
标签: c# winrt-xaml mvvm-light