1

wpf で画像を使用するには、次のように定義できます。

<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <BitmapImage x:Key="ImageFunTime"
                 UriSource="../Resources/Images/ImageFunTime.png" />
</

次に、アプリのどこかで次のことができます。

var img = (ImageSource)positionsTab.TryFindResource("ImageFunTime");

埋め込まれた Xslt ファイルで同じことを達成するにはどうすればよいですか? つまり、明らかにビットマップ画像ではないため、リソース辞書の構文は何ですか...

ティア

4

1 に答える 1

0

埋め込まれた Xslt ファイルで同じことを達成するにはどうすればよいですか?

答え:

  1. Microsoft の XSLT プロセッサはいずれも、組み込み XSLT スタイルシートをサポートしていません。XSLT スタイルシート用の完全な XSLT 専用ファイルが必要になります。

  2. XSLT では、ノードを一意に識別する何らかの文字列値によってノードを効率的に選択するための<xsl:key>命令と関数を使用します。key()

この変換:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 >
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:key name="UriSourceByKey"
  match="@UriSource" use="../@x:Key"/>

 <xsl:variable name="vImageFunTime"
  select="key('UriSourceByKey', 'ImageFunTime')"/>

 <xsl:template match="/">
  <xsl:value-of select="$vImageFunTime"/>
 </xsl:template>
</xsl:stylesheet>

この XML ドキュメントに適用した場合:

<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <BitmapImage x:Key="ImageFunTime"  UriSource="../Resources/Images/ImageFunTime.png" />
</ResourceDictionary>

必要な結果を生成します:

../Resources/Images/ImageFunTime.png
于 2010-05-19T03:20:47.920 に答える