H.B*_*.B. 6 wpf xaml assemblies xml-namespaces kaxaml
我可以让Kaxaml使用CLR命名空间加载外部程序集,但这很痛苦,因为需要大量映射来定位程序集中的所有不同命名空间,而程序集上的自定义XmlnsDefinition只允许一个或者一些.
在寻找解决方案时,我显然发现了这个问题,但它似乎只涵盖了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>
Run Code Online (Sandbox Code Playgroud)
这不起作用,但如果您使用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>
Run Code Online (Sandbox Code Playgroud)
该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>
Run Code Online (Sandbox Code Playgroud)
使用片段或默认文件,这可以变得相对方便,但仍然不理想,所以如果有人知道一个好的修复方法,请告诉我。
| 归档时间: |
|
| 查看次数: |
10913 次 |
| 最近记录: |