Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6841549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:58:50+00:00 2026-05-26T23:58:50+00:00

In MainWindow.xaml.cs I want to open another window. My code is this: WordToHtml.Window1 newForm

  • 0

In MainWindow.xaml.cs I want to open another window. My code is this:

WordToHtml.Window1 newForm = new WordToHtml.Window1();
newForm.Show();
return newForm.imagePath;

In Window1.xaml I have label, button and textBox. I want the user to click on the button and then I read the content from the textbox. However, when the breakpoint comes to newForm.Show();, the Window1 is shown but its invisible. It doesn’t have label/button etc. This is the code of Window1:

string imagePath;
public Window1() {
    InitializeComponent();
    label1.Content = @"Please enter path";
}
void button1_Click(object sender, RoutedEventArgs e) {
    //this is never entered because I can't see the button
}
public string newImagePath(string imagePath) {
    return imagePath;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:58:50+00:00Added an answer on May 26, 2026 at 11:58 pm

    The code snippet you are showing is not making somethings clear. I am pointing out my confusion & questions.

    1). I am assuming that when user clicks on some button on MainWindow, a new windows should open “Window1” where there is a label, button and textbox. then user enters some path in the textbox and clicks on the button the window1 should close and the imagepath should be available at “MainWindow” form. Please correct me if i am wrong.

    2). In this code snippet

      WordToHtml.Window1 newForm = new WordToHtml.Window1();
        newForm.Show();
        return newForm.imagePath;
    

    You will not get anything at “newForm.imagePath” or null or empty string as you are trying to access this before the user enters any value in the textbox.

    3). Using “SomeForm.Show()” method will open the new form which is not modal dialog means user can still get focus of “MainWindow” or click the button (that opens the new Window1 from). I suggest to use “newForm.ShowDialog()” window which returns focus to parent windows only when it is closed.

    4). You shold use

    newForm.Closing event to get the reference of the new form and before it is closed you can find the textbox control

    string imagePath  = (newForm.FindName("nameOfTextBox") as TextBox).Content.ToString();
    

    and get the imagepath in the MainWindow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my XAML code: <Window x:Class=CarFinder.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=Search for cars in TuMomo Height=480
I am creating a Kinect application and want to open a new window called
XAML code is below <Window x:Class=DenemeWpfApplication1.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow Height=350 Width=525> <Grid> <DockPanel Width=Auto
I would like to get the XAML source of a WPF Window (MainWindow). Clicking
In my application (WPF) i have this window: public partial class Window1 : Window
I am able to open a new window in a new thread by the
My app's main UI is in MainWindow.xaml. Firstly - what is causing this to
<Window x:Class=DataBinding_01.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow Height=350 Width=525> <StackPanel Height=Auto Name=stackPanel1 Width=Auto> <TextBox Height=23 Name=textBox1
In my MainWindow.xaml, I have added my UserControl to the Window. There is also
Guys, I have a basic WPF application. Contains App.xaml as always and a Mainwindow.xaml.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.