对事件使用Caliburn.Micro
简写语法时,我们如何传递Enum
(通过ValueConvertor)?
<MenuItem Header="Open" cal:Message.Attach="[Event Click]=[Action ShowDesigner(<what goes here ?>,'False')]"/>
ShowDesigner
方法sytax
ShowDesigner(eReportType,bool)
我已经写过StringToEnumValueconvertor
。
更新
EnumConvertor如下
public class StringToEnumConvertor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return Enum.Parse(typeof(eReportingTool), (string)value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
虽然枚举看起来像
public enum eReportingTool
{
StimulsoftReports = 1,
FastReport
}
答案 0 :(得分:1)
您不需要转换器从字符串转换为枚举,只需将您的枚举项目作为字符串传递。
cal:Message.Attach="[Event Click]=[Action ShowDesigner('StimulsoftReports','false')"