2013-12-12 25 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。它可能沒有加載到內存中。