2017-10-07 06:49:57 +08:00
## Selector SelectionChanged event and SelectedValue property
### Scope
Minor
### Version Introduced
4.7.1
### Source Analyzer Status
NotPlanned
### Change Description
2018-03-01 08:06:28 +08:00
Starting with the .NET Framework 4.7.1, a < xref:System.Windows.Controls.Primitives.Selector > always updates the value of its
2017-12-02 01:35:54 +08:00
< xref:System.Windows.Controls.Primitives.Selector.SelectedValue % 2A > property before raising the
2018-02-07 23:00:55 +08:00
< xref:System.Windows.Controls.Primitives.Selector.SelectionChanged > event, when its selection changes.
2017-10-07 06:49:57 +08:00
This makes the SelectedValue property consistent with the other selection properties
2017-12-02 01:35:54 +08:00
(< xref:System.Windows.Controls.Primitives.Selector.SelectedItem % 2A > and
2018-03-29 06:05:20 +08:00
< xref:System.Windows.Controls.Primitives.Selector.SelectedIndex % 2A > ), which are updated before raising the event.< p / >
2017-10-07 06:49:57 +08:00
In the .NET Framework 4.7 and earlier versions, the update to SelectedValue happened before the event in most cases, but it happened
after the event if the selection change was caused by changing the
2017-12-02 01:35:54 +08:00
< xref:System.Windows.Controls.Primitives.Selector.SelectedValue % 2A > property.
2017-10-07 06:49:57 +08:00
- [X] Quirked
- [ ] Build-time break
### Recommended Action
Apps that target the .NET Framework 4.7.1 or later can opt out of this change and use legacy behavior
by adding the following to the `<runtime>` section of the application configuration file:
```xml
< runtime >
2017-12-02 01:35:54 +08:00
< AppContextSwitchOverrides
value="Switch.System.Windows.Controls.TabControl.SelectionPropertiesCanLagBehindSelectionChangedEvent=true" />
2017-10-07 06:49:57 +08:00
< / runtime >
```
Apps that target the .NET Framework 4.7 or earlier but are running on the .NET Framework 4.7.1 or later can enable the new behavior by adding the following line to the `<runtime>` section of the application .configuration file:
```xml
< runtime >
< AppContextSwitchOverrides value = "Switch.System.Windows.Controls.TabControl.SelectionPropertiesCanLagBehindSelectionChangedEvent=false" / >
< / runtime >
```
### Affected APIs
* `P:System.Windows.Controls.TabControl.SelectedContent`
* `E:System.Windows.Controls.Primitives.Selector.SelectionChanged`
### Category
Windows Presentation Foundation (WPF)
<!--
### Original Bug
96884
-->