I have a tabbed GUI with each tab containing a Frame. In one of these Frames there is a DataGrid. When the user selects this tab, I need my datagrid sorted, so I'm using the TabControl SelectionChanged event to trigger the sort. However, this event triggers every time an item is selected from the DataGrid, even though the tabs themselves remain untouched.
I've tried number of different events: GotFocus for a TabItem RequestBringIntoView for a TabItem
but they all seem to suffer from this problem. What is causing this?
The ' |= ' symbol is the bitwise OR assignment operator.
In mathematics, the tilde often represents approximation, especially when used in duplicate, and is sometimes called the "equivalency sign." In regular expressions, the tilde is used as an operator in pattern matching, and in C programming, it is used as a bitwise operator representing a unary negation (i.e., "bitwise ...
C operators are one of the features in C which has symbols that can be used to perform mathematical, relational, bitwise, conditional, or logical manipulations. The C programming language has a lot of built-in operators to perform various tasks as per the need of the program.
In C/C++, the # sign marks preprocessor directives. If you're not familiar with the preprocessor, it works as part of the compilation process, handling includes, macros, and more.
The TabControl.SelectionChanged
is the same event as a ComboBox.SelectionChanged
It originates from Selector.SelectionChanged
.
So, if you do not mark your event as handled in your event handler, it will bubble up the tree, and eventually arrive at your TabControl
, which is causing this "firing too often" issue.
Mark your event as handled in your SelectionChanged of your ComboBox
/ListBox
/ListView
/any other Selector you use in your DataGrid like so:
private void MyComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { e.Handled = true; }
And this inconvenience will go away ;).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With