private void ListPDFDocuments_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (ListPDFDocuments.IsVisible) { ListPDFDocuments.UpdateLayout(); } }
public void FocusOnDocument(PDFDocument pdf_document_to_focus_on) { // Nothing to do here if (null == pdf_document_to_focus_on) { return; } // Find the selected document int selected_index = -1; int count = 0; List <AugmentedBindable <PDFDocument> > pdf_documents_bindable = (List <AugmentedBindable <PDFDocument> >)ListPDFDocuments.DataContext; foreach (AugmentedBindable <PDFDocument> pdf_document_bindable in pdf_documents_bindable) { PDFDocument pdf_document = pdf_document_bindable.Underlying; if (pdf_document == pdf_document_to_focus_on) { selected_index = count; } ++count; } try { if (-1 == selected_index) { GUITools.ScrollToTop(ListPDFDocuments); } else if (0 == selected_index) { ListPDFDocuments.SelectedIndex = selected_index; GUITools.ScrollToTop(ListPDFDocuments); } else { ListPDFDocuments.SelectedIndex = selected_index; ListPDFDocuments.UpdateLayout(); ListPDFDocuments.ScrollIntoView(pdf_documents_bindable[selected_index]); } } catch (Exception) {} }