-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
This issue has been moved from a ticket on Developer Community.
I've created a WPF application targeting .NET core. I have a GUI defined in a file named MainWindow.xaml The Main window displays fine when the program is executed. When the GUI runs there's, a button named "About". When the "About" button is clicked a new Window, named About is launched. The window launches fine but there's a big problem, regarding the content of the window that I cannot figure out.
The About Window is defined in file "About.xml", with text, and graphic objects that need to be shown when the window is launched. When the "About" button is clicked (MainWindow) there's a binding to a file named "ViewModelAdditionalInfo.cs" which calls a function "OnAboutSelected()"
This is what the "OnAboutSelected()" function looks like,
"private void OnAboutSelected()
{
// Ensure execution on the UI thread
Application.Current.Dispatcher.Invoke(() =>
{
AboutPage aboutWindow = new AboutPage();
// aboutWindow.Title = "About";
aboutWindow.ShowDialog();
});
}"
Note: In function OnAboutSelected() the line of code "aboutWindow.ShowDiaglog()" launches a new window defined in file "About.xaml" The problem is that the call to "aboutWindow.ShowDialog()" does NOT show any content that's defined in the "About.xaml" file - I only get a blank window showing no content. I've asked GitHub Copilot for suggestions, and it has stated everything looks right. The only thing I can think of is that I'm trying to open the new window (aboutWindow) on a thread that's not the same thread the MainWindow is running on. If you look at the code in function OnAboutSelcted() the Dispather.Invoke should make sure that the abouWindow is being launched on the same thread as the MwainWindow. Any ideas as to what I'm doing wrong would be greatly appreciated. Thanks.
Original Comments
Feedback Bot on 6/11/2025, 08:12 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Daniil Fominykh on 27/11/2025, 09:07 PM:
Candiago, Paul (P.) Do you have InitializeComponent ?
public partial class AboutPage : Window
{
public AboutPage()
{
InitializeComponent();
}
}