약간 실망 시간이
<Image Source="pack://application:,,,/{Binding ChannelInfo/ChannelImage}">
및
으로 시도 후
<Image Source="pack://siteoforigin:,,,/{Binding ChannelInfo/ChannelImage}">
및
<Image Source="/{Binding ChannelInfo/ChannelImage}">
나는이 내 자신의 변환을 구현 해결 어 :
C#을 측면 :
public class MyImageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string path= (string)value;
try
{
//ABSOLUTE
if (path.Length > 0 && path[0] == System.IO.Path.DirectorySeparatorChar
|| path.Length > 1 && path[1] == System.IO.Path.VolumeSeparatorChar)
return new BitmapImage(new Uri(path));
//RELATIVE
return new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + System.IO.Path.DirectorySeparatorChar + path));
}
catch (Exception)
{
return new BitmapImage();
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
XAML 측 :
<UserControl.Resources>
<local:ImageConverter x:Key="MyImageConverter" />
(...)
</UserControl.Resources>
<Image Source="{Binding Products/Image, Converter={StaticResource MyImageConverter}}">
건배,
세르지오
물론 - 작품 - 들으을! 응용 프로그램 폴더를 찾을 수있는 좋은 방법을 찾을 수 없습니다, 그래서 조금 해피 순간에 느낀다 .Net에서 GetApplicationFolder() 있나요? 하나를 찾을 수 없습니다 ..하지만 상대 경로 참조 어떻게 든 작동하지 않아야합니까? 그리고 나서 이들은 응용 프로그램 루트 폴더에 상대적입니까? 아니? – stiank81
Path.GetDirectoryName (Assembly.GetExecutingAssembly()를 시도하십시오.위치); –
그게 내가 사용하는 것과 같은 "Path.GetFullPath (". "),하지만 후자는 작업 폴더에 따라 달라질 것 같아요. 그래서 제안과 함께.이 문제를 좀 더있어,하지만 나는 그것을 알아낼 것입니다. Thx 당신의주의를 위해! – stiank81