내 응용 프로그램에서 사용자가 카메라 및 사진 라이브러리의 사진을 격리 된 저장소에 저장할 수 있도록 허용하고 있습니다. 그런 다음 각 파일의 이름을 가져 와서 사진을 읽고 내 목록에 추가하십시오. 목록이 작성되면 목록 상자에 바인딩합니다.목록 상자에 바인딩 할 때 XamlParseException
문제없이 약 5 개를 표시 할 수 있습니다. 나는 예외를 얻을 스크롤 한 후 :
<ListBox x:Name="userPhotosListBox">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel x:Name="DataTemplateStackPanel" Orientation="Horizontal">
<ContentControl Content="{Binding Image}" Width="400" />
<Image Name="{Binding FileName}" Source="/Images/appbar.delete.rest.png" Width="48" Height="48"
MouseLeftButtonUp="Image_MouseLeftButtonUp" VerticalAlignment="Center" HorizontalAlignment="Center" MaxWidth="48" MaxHeight="48" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
이 코드입니다 :
System.Windows.Markup.XamlParseException occurred
Message= [Line: 0 Position: 0]
--- Inner Exception ---
KeyNotFoundException
이 내 XAML입니다
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
var userFiles = store.GetFileNames();
foreach (var userFile in userFiles)
{
if (userFile.Contains(PhotoInIsolatedStoragePrefix))
{
var currentBitmap = ReadBitmapImageFromIso(userFile);
var userPhotoImage = new Image { Source = currentBitmap };
var userImg = new Img(userPhotoImage, userFile);
userPhotosListBox.Items.Add(userImg);
}
}
}
public class Img
{
public Img(Image img, string fileName)
{
this.Image = img;
this.FileName = fileName;
}
public Image Image { get; set; }
public string FileName { get; set; }
}
이유에 매우 WP7 개발에 새로운 혼란 내 코드가 부분적으로 작동합니다.
나는 삭제할 파일의 이름을 저장하기 위해 name 속성을 사용하고 삭제 아이콘을 표시하기 위해 소스를 사용하고 있습니다. 소스는 정적 "삭제"아이콘에 대한 참조입니다. –
파일 이름 형식은 무엇입니까? –
격리 된 저장소에 저장 한 다음 "userPhotoInISO-"접두사를 붙인 다음 GUID + ".jpg"를 생성합니다. 목록 상자에 바인딩 할 때 접두어가없는 파일 이름을 필터링합니다. __ApplicationSettings 파일은 제외됩니다. –