I have filmed my problem as it is easier to explain on video. I want the listbox to display the time began from the bookings table, that relies on the date from the bookings table and the room from the rooms table, is that possible.
Here is a link to the video: Video of problem
Here is the generated XAML:
This is for the grid:
This is for the calendar:
This is for the combobox:
And this is for the listbox:
Here is the generated C#
Here is a link to the video: Video of problem
Here is the generated XAML:
<CollectionViewSource x:Key="bookingsViewSource" d:DesignSource="{d:DesignInstance {x:Type local:Booking}, CreateList=True}"/><CollectionViewSource x:Key="roomsViewSource" d:DesignSource="{d:DesignInstance {x:Type local:Room}, CreateList=True}"/><CollectionViewSource x:Key="roomsBookingsViewSource" Source="{Binding Bookings, Source={StaticResource roomsViewSource}}"/><CollectionViewSource x:Key="bookingsBookingsViewSource" Source="{Binding Bookings, Source={StaticResource bookingsViewSource}}"/>
This is for the grid:
<Grid x:Name="Grid" SizeChanged="Grid_SizeChanged" Margin="0,0,-0.4,-0.2" DataContext="{StaticResource bookingsViewSource}" >
This is for the calendar:
<Calendar x:Name="MainCalendar" Margin="10,135.2,231.8,0" Grid.Row="2" ToolTip="Select a date" DisplayDateStart="2013-01-01" DisplayDateEnd="2020-01-01" FirstDayOfWeek="Monday" Height="177" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" SelectedDatesChanged="datechanged" DisplayDate="{Binding SelectedDate, RelativeSource={RelativeSource Self}}" SelectedDate=" {Binding Date, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" >
This is for the combobox:
<ComboBox x:Name="roomnameComboBox" Grid.Column="1" DisplayMemberPath="Room.Roomname" HorizontalAlignment="Left" Height="27" ItemsSource="{Binding}" Margin="3,5,0,0" Grid.Row="0" VerticalAlignment="Center" Width="120">
And this is for the listbox:
<ListBox x:Name="listrow" Grid.Column="1" Margin="3.2,1.2,1.8,0" Grid.Row="2" DisplayMemberPath="Timebegan" SelectionChanged="listrow_SelectionChanged" ItemsSource="{Binding Source={StaticResource bookingsBookingsViewSource}}"/>
Here is the generated C#
private void Bookings_Loaded(object sender, RoutedEventArgs e) { WpfApplication7.AllensCroftEntities1 allensCroftEntities1 = new WpfApplication7.AllensCroftEntities1(); // Load data into Bookings. You can modify this code as needed. System.Windows.Data.CollectionViewSource bookingsViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("bookingsViewSource"))); System.Data.Objects.ObjectQuery<WpfApplication7.Booking> bookingsQuery = this.GetBookingsQuery(allensCroftEntities1); bookingsViewSource.Source = bookingsQuery.Execute(System.Data.Objects.MergeOption.AppendOnly); // Load data into Rooms. You can modify this code as needed. System.Windows.Data.CollectionViewSource roomsViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("roomsViewSource"))); System.Data.Objects.ObjectQuery<WpfApplication7.Room> roomsQuery = this.GetRoomsQuery(allensCroftEntities1); roomsViewSource.Source = roomsQuery.Execute(System.Data.Objects.MergeOption.AppendOnly); } private System.Data.Objects.ObjectQuery<Booking> GetBookingsQuery(AllensCroftEntities1 allensCroftEntities1) { System.Data.Objects.ObjectQuery<WpfApplication7.Booking> bookingsQuery = allensCroftEntities1.Bookings; // To explicitly load data, you may need to add Include methods like below: // bookingsQuery = bookingsQuery.Include("Bookings.Client"). // For more information, please see http://go.microsoft.com/fwlink/?LinkId=157380 // Update the query to include Room.Bookings data in Bookings. You can modify this code as needed. bookingsQuery = bookingsQuery.Include("Room.Bookings"); // Returns an ObjectQuery. return bookingsQuery; } private System.Data.Objects.ObjectQuery<Room> GetRoomsQuery(AllensCroftEntities1 allensCroftEntities1) { System.Data.Objects.ObjectQuery<WpfApplication7.Room> roomsQuery = allensCroftEntities1.Rooms; // Update the query to include Bookings data in Rooms. You can modify this code as needed. roomsQuery = roomsQuery.Include("Bookings"); // Returns an ObjectQuery. return roomsQuery; }