Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Textboxes

Textboxes

Scheduled Pinned Locked Moved WPF
questionwpf
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    boiDev
    wrote on last edited by
    #1

    Hi I have two diffrent Windows .. Window1.xaml and Window2.xaml . Window2.xaml has a button and 3 text boxes.. and Window1.xaml has 3 textboxes aswell. I want to make it so that when i a user types is anything in Window2.xaml and then click the button it will copy the text and paste the text in Window1.xaml automatically .. how can i achive this.. :doh: ? Thanks in advance

    M M 2 Replies Last reply
    0
    • B boiDev

      Hi I have two diffrent Windows .. Window1.xaml and Window2.xaml . Window2.xaml has a button and 3 text boxes.. and Window1.xaml has 3 textboxes aswell. I want to make it so that when i a user types is anything in Window2.xaml and then click the button it will copy the text and paste the text in Window1.xaml automatically .. how can i achive this.. :doh: ? Thanks in advance

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      What is a "form"? If this is WPF, can you post an example of the XAML?

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      B 1 Reply Last reply
      0
      • M Mark Salsbery

        What is a "form"? If this is WPF, can you post an example of the XAML?

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        B Offline
        B Offline
        boiDev
        wrote on last edited by
        #3

        Sorry i did not mean form .. I meant like Window1.xaml and Window2.xaml....

        M 1 Reply Last reply
        0
        • B boiDev

          Sorry i did not mean form .. I meant like Window1.xaml and Window2.xaml....

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          Basically, you have TextBox elements with their associated Text properties, and you have a Button with a click event or an associated command. When the button is clicked you can get the values of the Text property of the TextBoxes and use them to set the Text properties of the TextBoxes in the other window. Which part of that are you having trouble with? It's hard to give a specific solution without knowing the structure of your code. There's so many different ways to achieve what you need. Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          B 1 Reply Last reply
          0
          • M Mark Salsbery

            Basically, you have TextBox elements with their associated Text properties, and you have a Button with a click event or an associated command. When the button is clicked you can get the values of the Text property of the TextBoxes and use them to set the Text properties of the TextBoxes in the other window. Which part of that are you having trouble with? It's hard to give a specific solution without knowing the structure of your code. There's so many different ways to achieve what you need. Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            B Offline
            B Offline
            boiDev
            wrote on last edited by
            #5

            Not to be of any bother .. Can you give a example on how to achieve it. Then i can expand from you example.. :-)

            M 1 Reply Last reply
            0
            • B boiDev

              Not to be of any bother .. Can you give a example on how to achieve it. Then i can expand from you example.. :-)

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              Here's an example of the two windows (XAML and code-behind), where the first window has the button.

              <Window x:Class="WPFTester.Window1"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              Title="Window1" Height="150" Width="300" Background="SteelBlue" Loaded="Window_Loaded" >
              <StackPanel>
              <TextBox Name="TextBox1" Margin="8" />
              <TextBox Name="TextBox2" Margin="8" />
              <Button Content="Test" Width="80" Margin="8" Click="TestButton_Click" />
              </StackPanel>
              </Window>

              namespace WPFTester
              {
              public partial class Window1 : Window
              {
              Window2 window2;

                  public Window1()
                  {
                      InitializeComponent();
                  }
              
                  private void Window\_Loaded(object sender, RoutedEventArgs e)
                  {
                      window2 = new Window2();
                      window2.Show();
                  }
              
                  private void TestButton\_Click(object sender, RoutedEventArgs e)
                  {
                      window2.TextBox1.Text = this.TextBox1.Text;
                      window2.TextBox2.Text = this.TextBox2.Text;
                  }
              }
              

              }

              <Window x:Class="WPFTester.Window2"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              Title="Window2" Height="116" Width="300" Background="SteelBlue" >
              <StackPanel>
              <TextBox Name="TextBox1" Margin="8" />
              <TextBox Name="TextBox2" Margin="8" />
              </StackPanel>
              </Window>

              namespace WPFTester
              {
              public partial class Window2 : Window
              {
              public Window2()
              {
              InitializeComponent();
              }
              }
              }

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              B 1 Reply Last reply
              0
              • M Mark Salsbery

                Here's an example of the two windows (XAML and code-behind), where the first window has the button.

                <Window x:Class="WPFTester.Window1"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                Title="Window1" Height="150" Width="300" Background="SteelBlue" Loaded="Window_Loaded" >
                <StackPanel>
                <TextBox Name="TextBox1" Margin="8" />
                <TextBox Name="TextBox2" Margin="8" />
                <Button Content="Test" Width="80" Margin="8" Click="TestButton_Click" />
                </StackPanel>
                </Window>

                namespace WPFTester
                {
                public partial class Window1 : Window
                {
                Window2 window2;

                    public Window1()
                    {
                        InitializeComponent();
                    }
                
                    private void Window\_Loaded(object sender, RoutedEventArgs e)
                    {
                        window2 = new Window2();
                        window2.Show();
                    }
                
                    private void TestButton\_Click(object sender, RoutedEventArgs e)
                    {
                        window2.TextBox1.Text = this.TextBox1.Text;
                        window2.TextBox2.Text = this.TextBox2.Text;
                    }
                }
                

                }

                <Window x:Class="WPFTester.Window2"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                Title="Window2" Height="116" Width="300" Background="SteelBlue" >
                <StackPanel>
                <TextBox Name="TextBox1" Margin="8" />
                <TextBox Name="TextBox2" Margin="8" />
                </StackPanel>
                </Window>

                namespace WPFTester
                {
                public partial class Window2 : Window
                {
                public Window2()
                {
                InitializeComponent();
                }
                }
                }

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                B Offline
                B Offline
                boiDev
                wrote on last edited by
                #7

                thank you :-D

                1 Reply Last reply
                0
                • B boiDev

                  Hi I have two diffrent Windows .. Window1.xaml and Window2.xaml . Window2.xaml has a button and 3 text boxes.. and Window1.xaml has 3 textboxes aswell. I want to make it so that when i a user types is anything in Window2.xaml and then click the button it will copy the text and paste the text in Window1.xaml automatically .. how can i achive this.. :doh: ? Thanks in advance

                  M Offline
                  M Offline
                  Mohammad Dayyan
                  wrote on last edited by
                  #8

                  AFAIK we can access to each elemant of a Window1.xaml with the namespace & class name of it.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups