views:

109

answers:

0

I've got an issue with data-binding with a WPF application I'm working on. Essentially I've got a class document which contains a IDocumentPaginatorSource property containing the contents of an XPS document. In my Main Window I've got a ScatterView which I create ScatterViewItems for programmatically. When a button is pressed, a new Document is created which I want to be displayed in a DocumentViewer in a ScatterViewItem, but I'm having problems getting the data to show.

The (cut down) Document class looks like so:

public partial class Document : UserControl {
     public IDocumentPaginatorSource DocumentContent { get; set; }
}

In my Main surface window I've got the following...

Document ADocument = new Document(); //then set the DocumentContent (not shown)
ScatterViewItem svi = new ScatterViewItem();
svi.BorderThickness = new Thickness(15.0);
svi.BorderBrush = Brushes.Orange;
svi.Content = ADocument;
MainScatterView.Items.Add(svi);

This adds the ScatterViewItem to the ScatterView just fine (with the proper border). How can I go about setting the data template for the ScatterViewItem to contain a DocumentViewer which I can then bind the DocumentContent to? I could set the ScatterViewItem content property directly to a DocumentViewer but I need to be able to access other properties of the Document later on, so the Content property needs to be a Document object.

I also cannot set the ScatterView ItemsSource property because my scatterview contains other (non-Document) objects.