6

CLR 名前空間を使用して Kaxaml に外部アセンブリをロードさせることはできますが、アセンブリのカスタム XmlnsDefinition では 1 つだけで済むのに対し、アセンブリ内のすべての異なる名前空間をターゲットにするために多くのマッピングが必要になるため、これは面倒です。またはいくつか。

解決策を探しているとき、私は明らかにこの質問を見つけましたが、カスタム名前空間ではどの回答も機能しないように見えたため、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空間はここでは使用されていないため、相互作用アセンブリのサブ名前空間を追加する必要がありました。

最初の方法を機能させることができれば理想的です。

4

1 に答える 1

4

したがって、この質問を入力しているときに、カスタム名前空間を使用する 1 つの方法に出くわしました: Kaxaml にアセンブリを少なくとも 1 回読み込ませる必要があります。

これは、参照されるアセンブリ内の 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>

スニペットまたはデフォルト ファイルを使用すると、これは理想的ではありませんが比較的便利になります。誰かが適切な修正を知っている場合はお知らせください。

于 2011-11-20T03:21:56.497 に答える