0

I have a desktop program with a WinRT/C++ library (and Microsoft.UI.Xaml.Controls 2.8 prerelease), which in the application will bring up a ContentDialog with a TextBox as its content. However, unfortunately the TextBox does not accept any character input from the keyboard, even though the TextBox is in a focused state. For the experiment so far, the TextBox can only accept input from the Copy and Paste methods. So, is there any workaround or manipulation that can be done to solve this problem?

Code:

TextBox tbox{};

ContentDialog dialog{};
dialog.Title(box_value(L"Title"));
dialog.Content(tbox);
dialog.PrimaryButtonText(L"Create");
dialog.CloseButtonText(L"Cancel");
dialog.XamlRoot(XamlRoot());

auto result = co_await dialog.ShowAsync();

if (result == ContentDialogResult::Primary)
{
    // Create new data from tbox.Text()
}
3
  • I've tried the code in a C++/winrt UWP project and it works well. Please check the TextBox.TextChanged Event to see if it fires Commented Mar 3, 2022 at 3:22
  • @RoyLi The TextBox.TextChanged event is not fired and the value of Text is not changed (null). Maybe you should try it in Win32 Project instead of UWP. Commented Mar 3, 2022 at 4:08
  • WinUI 2 doesn't directly support desktop applications. If you are using WinUI 2 in a desktop application, you're using XAML Islands. This requires non-trivial setup code we cannot see. Please show a minimal reproducible example. Commented Mar 3, 2022 at 8:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.