From d6f6dd39a7b59422ea49f5d8f41357ad36efb3d1 Mon Sep 17 00:00:00 2001 From: Micheal Colhoun Date: Wed, 24 May 2023 18:30:55 +0100 Subject: [PATCH] There was a problem with Samples/Windowing/cs-winui when using the TitleTextBox.Text.Contains method to find a match. Instead of displaying the expected error dialog, an exception was thrown with the error messages: "Value does not fall within the expected range." "The parameter is incorrect." "This element is already associated with a XamlRoot, it cannot be associated with a different one until it is removed from the previous XamlRoot." To fix this issue, the solution was to assign XamlRoot to this.XamlRoot. By making this assignment, the problem was resolved, and the exception was no longer thrown. Since you cannot paste the "\n" into the text box as it is not a multiline input, this code is unreachable and not tested. --- Samples/Windowing/cs-winui/WindowBasicsPage.xaml.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Samples/Windowing/cs-winui/WindowBasicsPage.xaml.cs b/Samples/Windowing/cs-winui/WindowBasicsPage.xaml.cs index 0fe2b07ee..3907c2a12 100644 --- a/Samples/Windowing/cs-winui/WindowBasicsPage.xaml.cs +++ b/Samples/Windowing/cs-winui/WindowBasicsPage.xaml.cs @@ -24,7 +24,8 @@ private async void TitleBtn_Click(object sender, RoutedEventArgs e) { Title = "Single line text only!", Content = "Only a single line of text is supported for a window titlebar. Please modify your text accordingly.", - CloseButtonText = "Ok" + CloseButtonText = "Ok", + XamlRoot = this.XamlRoot }; ContentDialogResult result = await errorDialog.ShowAsync(); }