I just find another case that will cause Null Reference, please reuse the code in my previous post
but this time it is to do with "PreservePositionWhenMaximized
In the code, there is a tile view model collection in the main view model to generate all tiles. First please remove the binding to TileState property to demonstrate this is an unrelated new bug. Then please set PreservePositionWhenMaximized="true"
in xaml and add a button that will regenerate different view model collection (in my case i always create a new collection with 4 tile view models), you will find that:
1, if all current tiles are restored, clicking the button will be fine
2, if first tile is maximized, clicking the button is also fine
3, if not-first tile is maximized, clicking the button will raise NullReferenceException