Open
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
protected internal object OnBringItemIntoView(object arg)
{
//
}
API Usage
I just want to be able use the same code as in ListBox
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.