我想打開一個新窗口,當它打開時,我想運行更多代碼來填充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");
}
}
}