我想打开一个新窗口,当它打开时,我想运行更多代码来填充TreeView。我想从命令中做到这一点,所以我不需要在窗口后面添加任何代码。加载其他窗口,加载时运行代码
这里是我的命令:
类> Commands.cs
/// <summary>
/// Command: SelectFolder
/// </summary>
#region SelectFolder
public static RoutedUICommand SelectFolder
{
get { return _SelectFolder; }
}
public static void SelectFolder_Executed(object sender,
ExecutedRoutedEventArgs e)
{
Window FolderDialog = new Views.FolderExplorer();
FolderDialog.Show();
//Bind Commands
Classes.MyCommands.BindCommandsToWindow(FolderDialog);
FolderDialog.ContentRendered += Functions.LoadFolderTree();
}
public static void SelectFolder_CanExecute(object sender,
CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
#endregion
收到此错误:
Cannot implicitly convert type 'void' to 'System.EventHandler'
An object reference is required for the non-static field, method, or property 'Functions.LoadFolderTree()'
目前,我试图运行一个函数然后会填充TreeView,但是如果有一个很好的方法可以从Command中执行,而不需要额外的功能,那么请说。这是我当前的代码:
类> Functions.cs
namespace Duplicate_Deleter.Classes
{
class Functions
{
public void LoadFolderTree()
{
MessageBox.Show("Hello");
}
}
}