注:リクエストにより、XAML および xaml.cs ファイルの完全なコードを追加しました。
WPFでは、次のDockPanel
ようなものを作成しました:
<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>
</Window>
プログラムで に を追加したいTreeView
のですDockPanel
が、Window1.xaml.cs で をDockPanel
名前で取得して追加することができません。
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 name 'ftpDock' does not exist in the current context"
私は単純なものを見逃したと確信しています。何か案は?