文本框的文本和Datacontext绑定在wpf到MVVM中

时间:2014-09-17 08:42:22

标签: wpf wpf-controls

.Xaml代码:

<TextBox Grid.Column="1" Name="txtRSINumber" Text="{Binding ListMembers.RSINumber,UpdateSourceTrigger=PropertyChanged}" DataContext="{Binding ListMembers, UpdateSourceTrigger=PropertyChanged}">
</TextBox>

MVVM类:

    public Member ListMembers
    {

        get
        {
            return _selectMember;
        }
        set
        {
            _selectMember = value;

            if (_selectMember.Id == 0)
            {
                ReadOnly();
                NotifyPropertyChanged("IsValidMember");
            }
            else
            {
                NotifyPropertyChanged("ListMembers");


            }
        }
    }

    public string RSINumber
    {
        get { return _rsiNumber; }
        set
        {
            _rsiNumber = value;
            NotifyPropertyChanged("RSINumber");
            _member.RSINumber = value;
        }
    }

问题:虽然datacontext绑定正在工作但是当我在文本框中输入任何文本时RSINumber绑定不起作用。如果我删除datacontext然后它工作正常但我需要两者。

0 个答案:

没有答案