Fix resource dictionary performance issues by calling BeginInit and EndInit

Fixes #946

Thanks @remcoros for the help!