1

Topic: WPF ListBox, validation

All greetings. Interests not  separate elements of a collection banished ItemsSource. And here such variant: when the collection is empty, a red frame and terrible ToolTip... <<RSDN@Home 1.0.0 alpha 5 rev. 0>>

2

Re: WPF ListBox, validation

DS> Interests not  separate elements of a collection banished ItemsSource. And here such variant: when the collection is empty, a red frame and terrible ToolTip All also as well as with TextBox. A working example: public ObservableCollection <VmSpecialty> SpecialtyListBox {get; private set;} = new ObservableCollection <VmSpecialty> (); public string this [string columnName] {get {var result = String. Empty; switch (columnName) {case "Fio": if (String. IsNullOrWhiteSpace (Fio)) result = "it is not entered ."; break; case "SpecialtyListBox": if (SpecialtyListBox. Count == 0) result = "specialities" are not selected; break; default: break;} return result;}} At adding, removal of elements from a collection, manually I cause OnPropertyChanged ("SpecialtyListBox");

3

Re: WPF ListBox, validation

Hello, s_aa, you wrote: DS>> Interests not  separate elements of a collection banished ItemsSource. And here such variant: when the collection is empty, a red frame and terrible ToolTip _> All also as well as with TextBox. A working example: _> _> public ObservableCollection <VmSpecialty> SpecialtyListBox {get; private set;} _> = new ObservableCollection <VmSpecialty> (); _> public string this [string columnName] _> {_> get _> {... _>} _>} _> _> At adding, removal of elements from a collection, manually I cause _> _> OnPropertyChanged ("SpecialtyListBox"); _> Eee... I so understand, it is implementation IDataErrorInfo? And INotifyPropertyChanged. And what class should implement them?... <<RSDN@Home 1.0.0 alpha 5 rev. 0>>

4

Re: WPF ListBox, validation

DS> Eee... I so understand, it is implementation IDataErrorInfo? And INotifyPropertyChanged. And what class should implement them? Yes, interfaces in ModelView a class for corresponding View are implemented.

5

Re: WPF ListBox, validation

Hello, s_aa, you wrote: DS>> Interests not  separate elements of a collection banished ItemsSource. And here such variant: when the collection is empty, a red frame and terrible ToolTip _> All also as well as with TextBox. A working example: <Grid> <Grid. RowDefinitions> <RowDefinition/> <RowDefinition Height = "Auto"/> </Grid. RowDefinitions> <ListBox Name = "Lst"/> <Button Grid. Row = "1" Content = "Add" Click = "Button_Click"/> </Grid> public sealed class MyCollection: ObservableCollection <string> {} public partial class Window2: Window {MyCollection MyCol = new MyCollection (); public Window2 () {InitializeComponent (); Lst. ItemsSource = MyCol;} void Button_Click (object sender, RoutedEventArgs e) {MyCol. Add ("sdgg");}} Where here to put IDataErrorInfo, INotifyPropertyChanged... <<RSDN@Home 1.0.0 alpha 5 rev. 0>>

6

Re: WPF ListBox, validation

I use MVVM, there interfaces are implemented in ViewModel. WPF in the manner of WinForms did not try to use, so to unwinding advise something I can not.

7

Re: WPF ListBox, validation

Hello, s_aa, you wrote: _> I Use MVVM, there interfaces are implemented in ViewModel. _> WPF in the manner of WinForms did not try to use, so to unwinding advise something I can not.  it is magnanimous... <<RSDN@Home 1.0.0 alpha 5 rev. 0>>