[英]Value Converter not resolved in XAML class
我有一個與不是UserControl后代的類相關聯的XAML文件。 我正在嘗試使用值轉換器將字符串轉換為POCO。 這個問題是我似乎無法讓轉換器被當作靜態資源使用。 我收到以下錯誤:
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; }
}
在此xaml之外聲明StreamFormatConverter
。 例如:在App.xaml中。 我認為您的Resources
不喜歡UserControl.Resources
。 它可能未加載到內存中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.