This question is locked. New answers and comments are not allowed.
Hi Telerik Team,
I'm trying to set the Databound Listbox's item source (previously Listbox only) with a LINQ query from to related tables 'Tapes' & 'TapeRetires', PK and FK is TapeID, with this code:
The Databound Listbox is filled with data from the TapeRetireItems(tr?), but I don't get the related
TapeName from TapeItems(t) displayed. I think that either my LINQ query is totally wrong or I can't
use/misuse a ObservableCollection as Itemsource? Or should I use ObservableCollection.ToList()?
If I try this LINQ query with LINQPad everything works fine, so I'm confused!
Any is hint or a better example is greatly appreciated!
Thanks!
Kind regards,
Joerg
I'm trying to set the Databound Listbox's item source (previously Listbox only) with a LINQ query from to related tables 'Tapes' & 'TapeRetires', PK and FK is TapeID, with this code:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Net;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Animation;
using
System.Windows.Shapes;
using
Microsoft.Phone.Controls;
using
PhoneApp4.Model;
using
System.Windows.Navigation;
using
System.Collections.ObjectModel;
using
System.ComponentModel;
namespace
PhoneApp4
{
public
partial
class
MainPage : PhoneApplicationPage, INotifyPropertyChanged
{
// Constructor
public
MainPage()
{
InitializeComponent();
this
.DataContext =
this
;
if
(allTapeRetireItems ==
null
)
allTapeRetireItems =
new
ObservableCollection<TapeRetire>();
// all
var tTapeRetireItems = from tr
in
App.Context.TapeRetireItems
join t
in
App.Context.TapeItems on tr.TapeID equals t.ID
select tr;
allTapeRetireItems =
new
ObservableCollection<TapeRetire>(tTapeRetireItems);
}
private
ObservableCollection<TapeRetire> m_TapeRetireItems;
public
ObservableCollection<TapeRetire> allTapeRetireItems
{
get
{
return
m_TapeRetireItems; }
set
{
if
(value != m_TapeRetireItems)
{
m_TapeRetireItems = value;
NotifyPropertyChanged(
"AllTapeRetireItems"
);
}
}
}
public
event
PropertyChangedEventHandler PropertyChanged;
void
NotifyPropertyChanged(
string
propertyName)
{
if
(PropertyChanged !=
null
)
PropertyChanged(
this
,
new
PropertyChangedEventArgs(propertyName));
}
}
}
The Databound Listbox is filled with data from the TapeRetireItems(tr?), but I don't get the related
TapeName from TapeItems(t) displayed. I think that either my LINQ query is totally wrong or I can't
use/misuse a ObservableCollection as Itemsource? Or should I use ObservableCollection.ToList()?
If I try this LINQ query with LINQPad everything works fine, so I'm confused!
Any is hint or a better example is greatly appreciated!
Thanks!
Kind regards,
Joerg