53: UWP WTF Error Messages version 3

Here is how anyone can reproduce it.

  • Create a custom control that is a MenuFlyoutItem and re-template it as this:
    <MenuFlyoutItem.Template>
        <ControlTemplate>
            <Grid x:Name="RootGrid" Width="280">
                 <HyperlinkButton Content="Microsoft home page" Click="{Binding  ElementName=Host, Path=ViewModel.SignoutCommand}" />
            </Grid>
        </ControlTemplate>
    </MenuFlyoutItem.Template>

See the red color there, it will fail at the compile time.

You can change it to

<TextBlock Text="Microsoft home page" Tapped="{Binding  ElementName=Host, Path=ViewModel.SignoutCommand}" />

Or

<Button Content="Microsoft home page" Click="{Binding  SignoutCommand}" />

Try binding a command in the DataContext or ViewModel, it will fail at the compile time.

As much as I love failing at the compile time because of error, I absolutely have no idea what the error message is trying to tell me in this case, since it is giving me this:

Xaml Internal Error error WMC9999: Object reference not set to an instance of an object.

What the hell is that?

It completely does not make sense.

Yes, the example is weird, I should not have a button inside a MenuFlyoutItem template. After all, a MenuFlyoutItem is clickable, I should not have another clickable item inside a clickable item. I agree, this example does not make sense. But again…

What the hell is that message trying to tell me?