ComboBox IsEnabled属性未更新

时间:2015-03-17 00:56:13

标签: c# wpf mvvm combobox isenabled

当多个属性(或“一起”)导致false时,我试图禁用ComboBox中的项目。我第一次点击ComboBox,属性'调用getter并显示正确的状态。每次在第一次之后单击ComboBox时,即使更改了属性(意味着启用/禁用状态应该不同),也不会再次检查属性。

这是我的ComboBox项目IsEnabled属性的代码:

<!--ItemContainer Style for disabling Combobox Item-->
        <ComboBox.ItemContainerStyle>
            <Style TargetType="ComboBoxItem">
                <Setter Property="IsEnabled" >
                    <Setter.Value>
                        <MultiBinding Converter="{StaticResource orConverterKkey}">
                            <!--<Binding  Source="{StaticResource vm}" Path="NotUseAngleRange" UpdateSourceTrigger="PropertyChanged"/>-->
                            <Binding  Path="IsAxisEnabled" UpdateSourceTrigger="PropertyChanged"/>
                            <Binding  Source="{StaticResource vm}" Path="IsFull180AngleRange" />
                        </MultiBinding>
                    </Setter.Value>
                </Setter>
            </Style>
        </ComboBox.ItemContainerStyle>

我缺少什么想法?

更新

我的视图模型和组合框项目实现了ViewModelBase,它实现了INotifyPropertyChanged

public class ViewModelReferenceAxisType : ViewModelBase
{
    public class ReferenceAxisTypeItem : ViewModelBase
    {
    ...
    }
}

public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable
{

    #region INotifyPropertyChanged Members

    /// <summary>
    /// Raised when a property on this object has a new value.
    /// </summary>
    public event PropertyChangedEventHandler PropertyChanged;

    /// <summary>
    /// Raises this object's PropertyChanged event.
    /// </summary>
    /// <param name="propertyName">The property that has a new value.</param>
    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = "")
    {
        this.VerifyPropertyName(propertyName);

        if (this.PropertyChanged != null)
        {
            var e = new PropertyChangedEventArgs(propertyName);
            this.PropertyChanged(this, e);
        }
    }

    #endregion // INotifyPropertyChanged Members

0 个答案:

没有答案