我有一个WPF程序,用Prism+Handycontrol,Tools.QuickFunctionModule和Tools.ModuleBase是两个独立的Module
1、在项目Tools.QuickFunctionModule里,有如下FileManagementView及FileManagementViewModel。
xaml代码:
xmlns:view="clr-namespace:Tools.ModuleBase.Views;assembly=Tools.ModuleBase"
<StackPanel>
<view:SelecteFilePathView />
<view:SelecteExportFolderPathView />
</StackPanel>
Viewmodel代码:
public DelegateCommand<string> SelectedFileCommand { get; set; }
private void OnSelectedFile(string obj)
{
switch (obj)
{
case "SourceFilePath":
string pathFile = FolderFileSelectHelper.SelectedFileOrFolder("File");
FileManagement.SourceFilePath = pathFile;
break;
case "OutFilePath":
string pathFolder = FolderFileSelectHelper.SelectedFileOrFolder("Folder");
FileManagement.OutFilePath = pathFolder;
break;
}
}
2、在项目Tools.ModuleBase里,有SelecteExportFolderPathView和SelecteFilePathView。
SelecteExportFolderPathView的代码:
<hc:SearchBar Command="{Binding SelectedFileCommand}"
CommandParameter="OutFilePath" />
SelecteFilePathView的代码:
<hc:SearchBar Command="{Binding SelectedFileCommand}"
CommandParameter="SourceFilePath" />
以上可以看到hc:SearchBar的Command="{Binding SelectedFileCommand}"是一样的,CommandParameter传参不一样,但是运行程序后,只有SelecteFilePathView能触发SelectedFileCommand,SelecteExportFolderPathView无法触发。该怎么解决?