【发布时间】:2016-09-01 05:06:39
【问题描述】:
我的应用中有一个模板菜单,里面有一个用于删除模板的菜单项。当没有现有模板时,菜单项被禁用。我将 IsEndabled 属性绑定到 Templates.Count 并且在 Windows 8 或 10 上一切正常,但在 Windows 7 上,该项目没有变灰(但被禁用)。
“删除模板...”菜单项的我的 xaml:
<MenuItem Header="{DynamicResource RemoveTemps}"
IsEnabled="{Binding Templates.Count,
Converter={StaticResource intToBoolConverter}}"
Command="{Binding RemoveTemplatesCommand, Mode=OneWay}"/>
ViewModel 类的片段:
public class MainWindowViewModel : ObservableObject
{
private StringCollection _templates = Properties.Settings.Default.Templates;
public ObservableCollection<string> Templates { get; set; } = new ObservableCollection<string>();
public MainWindowViewodel()
{
foreach (string s in _templates)
{
Templates.Add(s);
}
}
}
如果为了解决问题而缺少任何信息,请告诉我。
【问题讨论】: