2011-11-20 27 views
6

KaxamlにCLR-namespaceを使用して外部アセンブリを読み込ませることはできますが、これは厄介です。これはアセンブリ内のすべての異なる名前空間をターゲットにするためにアセンブリ上のXmlnsDefinitionを使用すると、1つまたは複数の要素だけを取り除くことができます。カスタムXML名前空間を使用してKaxamlの外部DLLを参照する

私は明らかに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を使用する場合はそれがない、動作しません。

is名前空間は、ここで使用されていないと私はのサブ名前空間を追加する必要がありました
<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> 

インタラクションアセンブリ。

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

答えて

4

この質問を入力しているうちに、私はカスタム名前空間を使う方法を見つけました。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> 

まだ理想的ではありませんしながら、誰かが私に教えてください良い修正を知っているので、もしこれが比較的便利に行うことができスニペットか、デフォルトのファイルを使用します。

関連する問題