title: FlowDocument with InlineUIContainer (image, datagrid) issues when creating XPS
body: <p>I'm trying to save a FlowDocument as a XPS. I'm using .Net 4.0.
  The FlowDocument contains the following elements:</p>
  
  <pre><code>    &lt;Paragraph&gt;
      &lt;InlineUIContainer BaselineAlignment="Center"&gt;
          &lt;Image Source="/MyNamespace;component/Images/logo.png"/&gt;
      &lt;/InlineUIContainer&gt;
  &lt;/Paragraph&gt;
  
      &lt;Paragraph&gt;
      &lt;Run Text="{Binding Path=TextBinding, FallbackValue='Oups, binding did not work'}"&gt;&lt;/Run&gt;
  &lt;/Paragraph&gt;
  
  &lt;InlineUIContainer&gt;
          &lt;DataGrid ItemsSource="{Binding Path=Items}" AutoGenerateColumns="False"
                    CanUserAddRows="False" RowHeaderWidth="0"&gt;
              &lt;DataGrid.Columns&gt;
                  &lt;DataGridTextColumn Header="Item Number"
                                      Binding="{Binding Path=Id}" Width="100" /&gt;
                  &lt;DataGridTextColumn Header="Description"
                                      Binding="{Binding Path=ItemDescription}" Width="200" /&gt;
              &lt;/DataGrid.Columns&gt;
          &lt;/DataGrid&gt;
      &lt;/InlineUIContainer&gt;
  </code></pre>
  
  <p>Everything works just fine when I display that FlowDocument within my WPF app.</p>
  
  <p>Now, I need to convert this into a XPS file on a server (I'd like to print in batch!).</p>
  
  <p>So I'm using the following code:</p>
  
  <pre><code>flowDocument.DataContext = myViewModel;
  
              Dispatcher.CurrentDispatcher.Invoke(DispatcherPriority.SystemIdle,
                                                  new DispatcherOperationCallback(arg =&gt; null), null);
  
   string xpsFilePath = String.Concat(@"c:\temp\", Guid.NewGuid(), ".xps");
  
          using (FileStream outputFile = new FileStream(xpsFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
          using (Package package = Package.Open(outputFile, FileMode.Create, FileAccess.ReadWrite))
          using (XpsDocument xpsDoc = new XpsDocument(package, CompressionOption.Maximum))
          {
              XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(xpsDoc), false);
              DocumentPaginator paginator = ((IDocumentPaginatorSource)flowDocument).DocumentPaginator;
              rsm.SaveAsXaml(paginator);
              rsm.Commit();
          }
  </code></pre>
  
  <p>And guess what? 
  1) The image is missing
  2) The DataGrid's empty, although the lines are drawn
  => Only the Run is displayed properly</p>
  
  <p>I tried all sorts of combinations found on the web, but it just never comes out propertly.
  And any non automated solution is just so out of the question!!!</p>
  
  <p>I can't wait for someone to rescue me!!!
  Thanks in advance</p>