Note that there are some explanatory texts on larger screens.

plurals
  1. POWP7 Select ObservableCollection Item using parameter passed from previous page
    primarykey
    data
    text
    <p>I have two table. Table 1 from a online service which forms the Listbox on my original Page. The second table is located in an internal DB and contains a uniqie field with the same values as a field in table1.</p> <p>I want to use a listbox in table 1 to load details from table2 in a seperate page.</p> <p>The code below is my code from my second page however it keeps throwing an exception "Items Collection must be empty before using ItemSource"</p> <p>Can someone correct this code or sugest better way to do this?</p> <pre><code>public partial class PlayerProfilePanoramaPage : PhoneApplicationPage { object _SelectedPlayer; string _playerName; public CollectionViewSource viewsource { get; set; } public PlayerProfilePanoramaPage() { InitializeComponent(); Loaded += new RoutedEventHandler(PhoneApplicationPage_Loaded); LoadPlayerProfile(); LoadPlayerDetails(); } private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { this.DataContext = _SelectedPlayer; } private void LoadPlayerProfile() { FrameworkElement root2 = Application.Current.RootVisual as FrameworkElement; var currentplayer = root2.DataContext as Mens_Leaders; _SelectedPlayer = currentplayer; _playerName = currentplayer.Name; } private void LoadPlayerDetails() { ObservableCollection&lt;PlayerProfileTable&gt; playerProfile = new ObservableCollection&lt;PlayerProfileTable&gt;(); viewsource = new CollectionViewSource(); viewsource.Filter += PlayerProfile_Filter; viewsource.Source = playerProfile; this.PlayerPanorama.ItemsSource = viewsource.View; } void PlayerProfile_Filter(object sender, FilterEventArgs e) { if (e.Item != null) e.Accepted = ((PlayerProfile)e.Item).Name.Equals(_playerName); } } </code></pre> <p>edit: Xaml is currently only simple to text that binding was working. Datacontexts and source bindings not defined in Xaml as defined in code. Xaml code provided below.</p> <pre><code>&lt;controls:Panorama Name="PlayerPanorama" Title="my application"&gt; &lt;!--Panorama item one--&gt; &lt;controls:PanoramaItem Name="panoramaPage1" Header="item1"&gt; &lt;Grid Name="Grid1"&gt; &lt;StackPanel&gt; &lt;TextBlock Height="30" Name="textBlock1" Text="{Binding PlayerName, FallbackValue=Name}" /&gt; &lt;TextBlock Height="30" Name="textBlock2" Text="{Binding Height, FallbackValue=Height}" /&gt; &lt;ScrollViewer Height="387" Name="scrollViewer1" Width="422"&gt; &lt;TextBlock Height="auto" Name="textBlock3" Text="{Binding ProfileBlurb, FallbackValue=Blurb}" /&gt; &lt;/ScrollViewer&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/controls:PanoramaItem&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload