I want create a new Window beside an existing main Windwoe with a scrollable Textbox.
I'm pressing in my main Window on a button "Open New Window" and then it should open a new Window with a scrollable Textbox.
inside form2
In WPF you can drag drop elements in the main Window but cant do that for a new window. So I thought it is only possible when you create a new window in the MainWindow.xaml.cs
I was able to create a new Window trough:
private void btnConnect_Click(object sender, RoutedEventArgs
{
Form form2 = new Form();
//Do intergreate TextBox with scrollbar in form2
form2.Show();
}
and now I want a Textbox
But how can I do that in C# or WPF?
Thx
well... you can create a new Window and load into this Windows.Content a UserControl wich you createt in a new XAML. Example:
NewXamlUserControl ui = new NewXamlUserControl();
MainWindow newWindow = new MainWindow();
newWindow.Content = ui;
newWindow.Show();
the Xaml is could be like this
<UserControl x:Class="Projekt"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="newXamlUserControl"
Height="300" Width="300">
<Grid>
<TextBox Text = ..../>
</Grid>
</UserControl>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With