Textboxes
-
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
-
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
What is a "form"? If this is WPF, can you post an example of the XAML?
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
What is a "form"? If this is WPF, can you post an example of the XAML?
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
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:
-
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:
-
Not to be of any bother .. Can you give a example on how to achieve it. Then i can expand from you example.. :-)
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:
-
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:
-
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
AFAIK we can access to each elemant of a Window1.xaml with the namespace & class name of it.