[API Proposal]: Make ItemsControl::OnBringItemIntoView protected
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
### Background and motivation
When inheriting from ItemsControl, there is no direct way to use the existing API, but it can be useful to have the possibility to use it.
### API Proposal
```csharp
protected internal object OnBringItemIntoView(object arg)
{
//
}
```
### API Usage
I just want to be able use the same code as in ListBox
```csharp
public void ScrollIntoView(object item)
{
if (ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
{
OnBringItemIntoView(item);
}
else
{
// The items aren't generated, try at a later time
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new DispatcherOperationCallback(OnBringItemIntoView), item);
}
}
```
### Alternative Designs
Perhaps a better alternative would be to bring the public method `ListBox::ScrollIntoView` up to `ItemsControl`. But make it virtual, as e.g. `ComboBox` needs some special love (see `ComboBoxAutomationProvider::ScrollItemIntoView`).
### Risks
Could break Applications when developers have a derived `ItemsControl` where they already have a `OnBringItemIntoView` method with the same signature. Or in case of the alternative a `ScrollIntoView` method.
Contributor guide
Assessment
This issue has not been assessed yet.