|
Не выполняется событие кнопки после события класса
|
|||
---|---|---|---|
#18+
Вот такой вопрос: Есть DataGrid, которая заполняется из ObservableCollection с данными из класса: public class onSh : INotifyPropertyChanged, IDataErrorInfo. // привожу пример одного столбца public string cN2 { get { return car2; } set { car2 = value; onPropertyChanged(this, "cN2"); } } private string car2; public event PropertyChangedEventHandler PropertyChanged; private void onPropertyChanged(object sender, string propertyName) { if (this.PropertyChanged != null) { PropertyChanged(sender, new PropertyChangedEventArgs(propertyName)); } } public string Error { get { StringBuilder error = new StringBuilder(); // iterate over all of the properties // of this object - aggregating any validation errors PropertyDescriptorCollection props = TypeDescriptor.GetProperties(this); foreach (PropertyDescriptor prop in props) { String propertyError = this[prop.Name]; if (propertyError != string.Empty) { error.Append((error.Length != 0 ? ", " : "") + propertyError); } } return error.Length == 0 ? null : error.ToString(); } } public string this[string name] { get { string result = null; if (this.priznCheck == 0) return result; // saf if (name == "cN2") { try { if (this.car2() != "" && this.car2 != null) { ... } } catch { result = "Ошибка"; } } return result; } } Есть кнопка SAVE1, по которой данные из коллекции должны быть перенесены в базу: <Button Content="Сохранить" HorizontalAlignment="Left" Margin="3,1,86,0" Name="SAVE1" Width="70" Click="save1_Click" Style="{StaticResource Button1}" Height="22" VerticalAlignment="Top" Grid.ColumnSpan="2" /> private void save1_Click(object sender, RoutedEventArgs e) { // Сохранить ... После редактирования ячейки DataGrid происходит проверка на правильность введенных данных с помощью PropertyChangedEventHandler Проблема в том, что если после изменения какой-либо ячейки нажать кнопку SAVE1, то выполняется проверка введенных данных в классе, но после этого к событию кнопки save1_Click переход отсутствует (т.е. база не обновляется). Если же нажать второй раз кнопку, то тогда база обновится. Как это выполнить с одним нажатием кнопки SAVE1? ... |
|||
:
Нравится:
Не нравится:
|
|||
24.07.2014, 17:41 |
|
Не выполняется событие кнопки после события класса
|
|||
---|---|---|---|
#18+
Забыла дать описание столбца DataGrid: <DataGridTextColumn Header="Вагон" Binding="{Binding Path=cN, Mode=TwoWay, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" EditingElementStyle="{StaticResource errorStyle}" ElementStyle="{StaticResource errorStyle1}" CellStyle="{StaticResource GridCell1}" Width="70" MaxWidth="70" /> ... |
|||
:
Нравится:
Не нравится:
|
|||
24.07.2014, 17:46 |
|
|
start [/forum/topic.php?fid=21&fpage=22&tid=1441078]: |
0ms |
get settings: |
6ms |
get forum list: |
13ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
39ms |
get topic data: |
13ms |
get forum data: |
3ms |
get page messages: |
45ms |
get tp. blocked users: |
1ms |
others: | 288ms |
total: | 416ms |
0 / 0 |