0
這是一個非常奇怪的問題,這是我正在處理的最後一個頁面,我曾經使用ListBox的ObservableCollection將數據添加到文本塊和圖像中並綁定數據。WP7中的DataBinding問題
但是這次我只有1個TextBlock和1個圖像,我需要將數據綁定到它。 在.cs文件中,我無法直接訪問它們,也無法使用DataBinding。
的XAML:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Text="{Binding lastName}" Height="33" Margin="0,175,8,0" TextWrapping="Wrap" VerticalAlignment="Top" HorizontalAlignment="Right" Width="336" />
<ListBox ItemsSource="{Binding lastAddress}" Margin="8,291,8,8"/>
<TextBlock HorizontalAlignment="Left" Height="33" Margin="8,0,0,0" TextWrapping="Wrap" Text="Restaurant Profile: " VerticalAlignment="Top" Width="225" TextDecorations="Underline" Foreground="#FF7A0100" FontSize="24"/>
<Image Source="{Binding lastImage}" Height="132" Margin="8,37,292,0" VerticalAlignment="Top" Stretch="None"/>
</Grid>
任何幫助嗎? 謝謝。
你能在你設置你的'DataContext'的代碼添加。這將有所幫助。 – peterept 2012-02-10 01:29:22