//The method when a checkbox is checked to select the other rows if multiple are selected private void CheckBox_Checked(object sender, RoutedEventArgs e) { //Cast the selected items in the ListView to a List of the ViewSheets class List <ViewSheetsIdName> TempSheets = ListViewSheets.SelectedItems.Cast <ViewSheetsIdName>().ToList(); //iterate through each of the ViewSheets items in that list foreach (ViewSheetsIdName Sheet in TempSheets) { //Try and find the item in the main SheetList list and get that object //We can't directly change the SheetList because we have linked it to the Listview //and we are using NotifyPropertyChanged events so that is why we need temp items ViewSheetsIdName item = SheetList.Find(x => x.SheetId == Sheet.SheetId); //set the bool Check variable to true or checked item.Check = true; } }
//Pprovide a method to show the preview of the sheet from the Context Menu item private void MenuItem_Click(object sender, RoutedEventArgs e) { //Get the selected item from the list view and cast that to our custom ViewSheetsIdsName calss ViewSheetsIdName sheet = (ViewSheetsIdName)ListViewSheets.SelectedItem; //Create a new instance of the SheetPreviewForm and change the caption to the Sheet Number & Name Forms.SheetPreviewForm prvForm = new Forms.SheetPreviewForm() { Text = sheet.SheetName }; //Add a new PreviewControl to the ElementHost retreived through the public property on the form. //You need the current Document and the ElementId of the view to display, a Sheet in this case prvForm.PreviewHost.Child = new PreviewControl(doc, sheet.SheetId); //Show the form as a dialog prvForm.ShowDialog(); }