Skip to content

Missing Critical Line of Code #95

Description

The example showing how to open the ContentDialog from within a window's event handler is missing a critical line of code, at least under the current version of WinUI 3:

private async void ShowLog_Click( object sender, RoutedEventArgs e )
{
    var dlg = new LogViewer();

    // this line is critical; without it, you get an obscure WinRT error message
     dlg.XamlRoot = App.Current.MainWindow!.Content.XamlRoot;

     await dlg.ShowAsync();
}

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions