I'm working on an MVVM application that has a Save button that I'd like to disable if the Title field is empty.
Here's the code for the delegatecommand:
_clickSaveChangesCommand = new DelegateCommand<string>(
(s) => { saveStudentRecord(); //execute },
(s) => { return (_student.Title != null); /*Can execute*/ }
);
Here's the binding:
<TextBox Name="fldTitle" Text="{Binding Path=Student.Title, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="300" Height="27" />
When I update the student object from within the viewmodel, it works as expected. If, however, I create a new record and type something into the textbox, the button remains not executable. In my testing, if I try to show the value of _student.Title it shows with the value as expected.