如何从另一个“松散 Xaml”定义的活动调用“松散 Xaml”定义的活动?

发布于 2024-12-27 14:53:34 字数 611 浏览 0 评论 0原文

我有两个“松散”的 XAML 文件,每个文件都以声明方式定义由一些自定义(编译的)代码活动组成的复合活动。

现在,我希望第一个“松散”Xaml 中定义的活动“包含”第二个“松散”Xaml 中定义的活动的步骤。

但是,我不知道如何将两个活动“粘合”在一起,以便第一个活动知道从第二个 Xaml 正确加载活动。

因此,在调用时:

XamlXmlReader xr = new XamlXmlReader(@"FirstLooseActivity.xaml");
ActivityBuilder ab = (ActivityBuilder)XamlServices.Load(ActivityXamlServices.CreateBuilderReader(xr));

我最终遇到 XamlObjectWriterException (在将所有相关程序集加载到托管应用程序后):

Cannot create unknown type '{clr-namespace:SecondLooseActivity}MyActivity

由于 MS 中没有 Xlink 支持,有没有办法做到这一点?

如果没有,我有什么选择?

I have two "loose" XAML files, each declarativly defining composite activity which is composed of some custom (compiled) code-activities.

Now, I would like the activity defined in the 1st "loose" Xaml to 'contain' the activity defined in the 2nd "loose" Xaml as of its steps.

However, I have no clue how to 'glue' both activities together such that 1st activity will know to correctly load the activity from the 2nd Xaml.

So when calling:

XamlXmlReader xr = new XamlXmlReader(@"FirstLooseActivity.xaml");
ActivityBuilder ab = (ActivityBuilder)XamlServices.Load(ActivityXamlServices.CreateBuilderReader(xr));

I end up with a XamlObjectWriterException (after I loaded all relevant assemblies to my hosting app):

Cannot create unknown type '{clr-namespace:SecondLooseActivity}MyActivity

Since there is no Xlink support in MS, is there a way to do this at all?

If not, what are my alternatives?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情释 2025-01-03 14:53:34

我遇到了完全相同的问题并找到了解决方案。

我的 XAML 如下所示:

<Activity ... xmlns:mylib="clr-namespace:MyProject.ActivityLibrary">
    <mylib:MyCustomActivity ... />
</Activity>

对我有用的技巧是在命名空间中指定包含我的自定义活动的程序集。

将命名空间更改为此使其工作:

xmlns:mylib="clr-namespace:MyProject.ActivityLibrary;assembly=MyProject.ActivityLibrary"

I had the exact same issue and found a solution.

Here's what my XAML looked like this:

<Activity ... xmlns:mylib="clr-namespace:MyProject.ActivityLibrary">
    <mylib:MyCustomActivity ... />
</Activity>

The trick that worked for me was to specify the assembly containing my custom activity in the namespace.

Changing the namespace to this made it work:

xmlns:mylib="clr-namespace:MyProject.ActivityLibrary;assembly=MyProject.ActivityLibrary"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文