Hi,
i think your problem is that you have to lists...in each Window is one List of Type List<tripinfo>.
Declare in Window1 instead of the list a othe property:
public TripInfo tripInfo;
and
fill this Porperty in the Click Event
private void button1_Click(object sender, RoutedEventArgs e)
{
tripInfo = new TripInfo(false, textBox1.Text);
this.Hide();
}
then you access the property in your MainForm on the AssgnLesson Button and say ShowDialog() so Code will Block till you close Window1
private void btn_AssgnLesson_Click(object sender, RoutedEventArgs e)
{
Window1 wd1 = new Window1();
wd1.ShowDialog();
tripList.Add(wd1.tripInfo);
listLesson.ItemsSource=tripList;
}
Thats all but you make your live easier if you set the Itemsource in Xaml and take instaed of List the ObservableCollection
public ObservableCollection<tripinfo> tripList {get;set;}
public MainWindow()
{
InitializeComponent();
DataContext = this;
}</tripinfo>
In Xaml it looks like
<ListBox ItemSource="{Binding Path=tripList }" Grid.Column="1" Grid.RowSpan="2" Height="128" HorizontalAlignment="Left" Margin="13,6,0,0" Name="listLesson" Selector.IsSelected="{Binding IsChecked, ElementName=checkBox, Mode=TwoWay}" VerticalAlignment="Top" Width="194">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox Margin="2" VerticalAlignment="Center" IsChecked="{Binding IsVisited}" />
<TextBlock Margin="2" Foreground="Black" FontSize="14" Text="{Binding LessonName}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Hope it helps
Sorry but i actually can´t send my code trough the compiler and check if syntax etc. is allover corect