wpf – 使用自定义XML命名空间引用Kaxaml中的外部DLL
发布时间:2020-12-16 05:37:09 所属栏目:百科 来源:网络整理
导读:我可以让Kaxaml使用CLR命名空间加载外部程序集,但这很痛苦,因为需要大量映射来定位程序集中的所有不同命名空间,而程序集上的自定义XmlnsDefinition只允许一个或者一些. 在寻找解决方案时,我显然找到了this question,但它似乎只涵盖了CLR命名空间的使用,因为
我可以让Kaxaml使用CLR命名空间加载外部程序集,但这很痛苦,因为需要大量映射来定位程序集中的所有不同命名空间,而程序集上的自定义XmlnsDefinition只允许一个或者一些.
在寻找解决方案时,我显然找到了this question,但它似乎只涵盖了CLR命名空间的使用,因为没有任何答案似乎适用于自定义命名空间(“无法设置未知成员……”). 例: <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:is="http://schemas.microsoft.com/expression/2010/interactions"> <!-- ... --> <Button Content="Test"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <is:ChangePropertyAction PropertyName="IsOpen" TargetName="popup" Value="True" /> </i:EventTrigger> </i:Interaction.Triggers> </Button> 这不起作用,但如果您使用CLR,它会: <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:is="clr-namespace:Microsoft.Expression.Interactions;assembly=Microsoft.Expression.Interactions" xmlns:isc="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"> <!-- ... --> <Button Content="Test"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <isc:ChangePropertyAction PropertyName="IsOpen" TargetName="popup" Value="True" /> </i:EventTrigger> </i:Interaction.Triggers> </Button> 这里没有使用is命名空间,我必须添加交互程序集的子命名空间. 如果可以使第一种方法起作用,那将是理想的.
所以在输入这个问题时我偶然发现了一种使用自定义命名空间的方法:你必须让Kaxaml加载程序集至少一次.
这可以使用一些引用引用程序集中的CLR命名空间的虚拟对象来完成.如果解析一旦这个加载器可以被丢弃,当然这需要在每次运行Kaxaml时完成. <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:is="http://schemas.microsoft.com/expression/2010/interactions"> <Page.Resources> <FrameworkElement x:Key="loader" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:is="clr-namespace:Microsoft.Expression.Interactions;assembly=Microsoft.Expression.Interactions" /> </Page.Resources> 使用片段或默认文件这可以比较方便,但仍然不理想,所以如果有人知道一个好的修复,请告诉我. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- C#字段(field)
- org.xml.sax.SAXParseException: The content of elements
- stm32—FatFs移植spi_flash(报错FR_NO_FILESYSTEM)
- Ajax用户名验证、服务条款加载、验证码生成
- 如何在PostgreSQL / pgAdmin III中将bytea数据作为十六进制
- 操作JSONObject中的某一个bean
- c# – 我最近开始自己学习WPF.声明名称与x:名称有什么区别
- 查看正则表达式重复是否可以减少的算法
- Cocos2d-x 整理 SDK,易接流程(写给自己看的
- ruby-on-rails – 如何在使用render_to_string后正常渲染视