當我嘗試將XAML中的圖像綁定到位於其後的代碼中的bitmapImage對象時,會給我 '當前上下文中不存在'錯誤。當前上下文中不存在錯誤
代碼
BitmapImage bitmapImage = new BitmapImage();
PhotoSource.Source = bitmapImage;
ObservableCollection<BitmapImage> Photos = new ObservableCollection<BitmapImage>();
PhotoList.ItemsSource = Photos;
XAML
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,5,12,-10">
<ProgressBar x:Name="progressBar" HorizontalAlignment="Left" Height="40" Margin="0,0,0,0" VerticalAlignment="Top" Width="436" Visibility="Collapsed" IsIndeterminate="True"/>
<ListBox x:Name="PhotoList"
toolkit:TiltEffect.IsTiltEnabled="True"
SelectionChanged="PhotoList_SelectionChange"
HorizontalAlignment="Left" Height="500" Margin="0,40,0,0" VerticalAlignment="Top" Width="450">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel
HorizontalAlignment="Left"
Margin="0,0,0,0"
VerticalAlignment="Top"
/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="5">
<StackPanel Orientation="Vertical">
**<Image delay:LowProfileImageLoader.UriSource="{Binding PhotoSource}" Width="99" Height="80"/>**
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
您需要創建這樣的屬性。 – SLaks
錯誤是不言自明的 - 'PhotoSource'不存在。 –
雅,但它確實: –
LivingThing