我需要创建Activity Designer,我可以在其中编辑其参数。 我有一个Activity通过其位置路径加载另一个活动XAML。
[Designer(typeof(LoadSubTreeActivityDesigner))]
public class LoadSubTree : NativeActivity
{...}
在活动设计器中,我加载代表我的Activity的View和Viewmodel:
<sap:ActivityDesigner x:Class="Cellebrite.Diagnostics.WF.Activities.Designers.LoadSubTreeActivityDesigner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation"
xmlns:common="clr-namespace:Cellebrite.Diagnostics.WF.Activities.Common">
<FrameworkElement.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
</FrameworkElement.Resources>
<ContentPresenter ContentTemplate="{StaticResource {x:Static common:Constants.SubTreeLoadingDataTemplate}}"
Visibility="{Binding Path=ShowExpanded,Converter={StaticResource BooleanToVisibilityConverter},RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type sap:ActivityDesigner}}}" />
</sap:ActivityDesigner>
Command&#34; Open Editor&#34;屏幕截图显示了编辑参数的对话框:
这是如何打开我在互联网上找到的编辑器对话框的代码:
public ICommand DefineArgsCommand
{
get
{
return new DelegateCommand(param =>
{
ModelItem model = param as ModelItem;
var options = new DynamicArgumentDesignerOptions()
{
Title = "Edit Arguments"
};
var modelItem = model.Properties["Arguments"]?.Dictionary;
using (ModelEditingScope change = modelItem.BeginEdit("ChildArgumentEditing"))
{
if (DynamicArgumentDialog.ShowDialog(model, modelItem, model.GetEditingContext(), model.View, options))
{
change.Complete();
}
else
{
change.Revert();
}
}
}, param => true);
}
}
此对话框是MS System.Activities.Core.Presentation.dll
的一部分,所有子类都是内部或私有的。
有人知道如何在使用model.Properties["Arguments"]?.Dictionary
旁边手动向DynamicArgumentDialog
添加参数吗?
我无法识别此对象期望接收的类型,并且当我尝试不同的变体时,我会收到运行时异常。
有人知道如何以其他方式编辑参数吗?