2013-12-12 27 views
0

我有一个与不是UserControl后代的类关联的XAML文件。我正尝试使用值转换器将字符串转换为POCO。这个问题是我似乎无法得到转换器被选为静态资源。我收到以下错误:Value Converter未在XAML类中解析

The resource "myConverter" could not be resolved. 

任何想法?

XAML

<blst:StreamFactory 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:blst="clr-namespace:myNamespace"> 

    <blst:StreamFactory.Resources> 
     <blst:StreamFormatConverter x:Key="MyConverter"/> 
    </blst:StreamFactory.Resources> 

    <blst:StreamFactory.AvailableStreams> 
     <blst:StreamInfo> 
      <blst:StreamInfo.Format> 
       <Binding Converter="{StaticResource MyConverter}" ConverterParameter="MP3"/> 
      </blst:StreamInfo.Format> 
     </blst:StreamInfo> 
    </blst:StreamFactory.AvailableStreams> 

</blst:StreamFactory> 

C#

class StreamFactory 
    { 
     public ResourceDictionary Resources { get; set; } 

     public List<StreamInfo> AvailableStreams { get; private set; } 
    } 

回答

0

声明StreamFormatConverter此XAML外部。例如:在App.xaml中。我认为你的Resources不喜欢UserControl.Resources。它可能没有加载到内存中。