我試圖在WF 4.5工作流活動中實現瀏覽文件夾,但省略號按鈕沒有顯示,幾乎沒有任何反應。Windows工作流設計器4.5(瀏覽文件夾)中的UITypeEditor
這是我的UITypeEditor的類:
public class BrowseForFolderEditor : UITypeEditor
{
public override object EditValue(ITypeDescriptorContext context,
IServiceProvider provider, object value)
{
string folderName = string.Empty;
BrowseForFolderAttribute browseForFolderAttribute = null;
if (value is string)
{
if (context?.PropertyDescriptor != null)
{
browseForFolderAttribute =
(BrowseForFolderAttribute)
context.PropertyDescriptor.Attributes[typeof(BrowseForFolderAttribute)];
}
var browse = new FolderBrowserDialogEx
{
Description = browseForFolderAttribute?.Description,
ShowNewFolderButton = true,
ShowEditBox = true,
SelectedPath = folderName,
ShowFullPathInEditBox = false,
RootFolder = Environment.SpecialFolder.MyComputer
};
var result = browse.ShowDialog();
if (result == DialogResult.OK)
folderName = browse.SelectedPath;
return folderName;
}
// Return whatever value if it wasn't a string - Should never occur!
return value;
}
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal; //base.GetEditStyle(context);
}
public class BrowseForFolderAttribute : Attribute
{
public BrowseForFolderAttribute(string description)
{
this.Description = description;
}
public string Description { get; set; }
}
}
這是怎麼我在Activity
聲明代碼:
[Description("Select the folder where the files will be
copied/moved to.")]
[Category("Folders")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
[BrowseForFolderEditor.BrowseForFolder("Select the folder where the files will be
copied/moved to.")]
[Editor(typeof(BrowseForFolderEditor), typeof(UITypeEditor))]
public string TargetPath { get; set; }
我不知道這有什麼差別,但我的工作流程Activity
是NativeActivity
。
屬性顯示在屬性網格中,但它僅顯示爲不帶省略號按鈕的文本框。
任何幫助,將不勝感激。
UPDATE-1:
的問題沒有什麼關係的事實,這是一個NativeCodeActivity
因爲我剛剛改變了我的代碼CodeActivity
,並沒有什麼區別。