I couldn't find a proper event which fires when my ComboBox.Items count changed. Is there any way to do so?
相关问题
- VNC control for WPF application
- Stop child process when parent process stops
- Fire resize event once not based on timing
- WPF Binding from System.Windows.SystemParameters.P
- XAML: Applying styles to nested controls
Bind ComboBox ItemsSource to ObservableCollection, then you can catch the event CollectionChanged of ObservableCollection
EDIT:
In wpf it is recommended to use binding instead of accessing UI element properties directly, of course better to use MVVM, but you can live without it too
in your Windows or UserControls C# code you can keep property like this
Initialize it in constructor
than name your UserControl in xaml like this
write your ComboBox like this
now instead of adding and removing items to combobox element, add tham to MyCollection, they will appear in combobox
Hope this helps
Don't think that there is any event to fire when ComboBox.Items count changed. You probably should do the code when you add or remove the items.
OR