Note:By Request, I have added the full code for my XAML and xaml.cs files
In WPF, I have created a DockPanel like so:
<Window
x:Class="RealEditor.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="RealEditor" Height="500" Width="700"
>
<DockPanel>
<GridSplitter Grid.Column="1" Width="4" HorizontalAlignment="Left"/>
<DockPanel x:Name="ftpDock" Grid.Row="1" Grid.Column="1"></DockPanel>
</Grid>
</DockPanel>
I want to programmatically add a TreeView to the DockPanel, but in Window1.xaml.cs, I am unable to get the DockPanel by name, and add to it:
namespace RealEditor
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
TreeViewItem mytreeView = new TreeViewItem();
ftpDock.Children.Add(myTreeView);
}
}
}
The above code returns the following error:
"The name 'ftpDock' does not exist in the current context"
I am sure I have just missed something simple. Any ideas?