Prevent IndexOutOfRange exception.
Prevent IndexOutOfRange exception.

Prevent the exception described in https://github.com/AvaloniaUI/Avalonia/pull/2603#issuecomment-508011071. This makes our codebase diverge from WinUI's but Im unable to debug into the WinUI code consistently enough to work out why this problem doesn't show up there.

jkoritzinsky/Avalonia,SuperJMN/Avalonia,AvaloniaUI/Avalonia,SuperJMN/Avalonia,jkoritzinsky/Avalonia,jkoritzinsky/Avalonia,wieslawsoltes/Perspex,wieslawsoltes/Perspex,jkoritzinsky/Avalonia,Perspex/Perspex,SuperJMN/Avalonia,SuperJMN/Avalonia,grokys/Perspex,jkoritzinsky/Avalonia,SuperJMN/Avalonia,AvaloniaUI/Avalonia,wieslawsoltes/Perspex,AvaloniaUI/Avalonia,wieslawsoltes/Perspex,grokys/Perspex,wieslawsoltes/Perspex,wieslawsoltes/Perspex,SuperJMN/Avalonia,AvaloniaUI/Avalonia,AvaloniaUI/Avalonia,jkoritzinsky/Perspex,wieslawsoltes/Perspex,jkoritzinsky/Avalonia,Perspex/Perspex,AvaloniaUI/Avalonia,akrisiun/Perspex,SuperJMN/Avalonia,AvaloniaUI/Avalonia,jkoritzinsky/Avalonia