0

I would like to print a user control with data binding. I'm very confused about this and don't even know if it is possible. I have a class which implements DocumentPaginator and I would like to do something like this:

public override DocumentPage GetPage(int pageNumber)
{
    UserControl myUC = new View.MyUserControl();
    myUC.DataContext = this;
    return new DocumentPage(myUC);
}

The xaml of myUC user control contains a label like the following:

   <Label Content="{Binding myName}" FontSize="18"  Height="20"/>

where myName is a property defined in the class.

The user control is correctly printed but the binding is not applied. Is it possible some way ? What can I do ?

Please considered this is an extremely simplified example of what I would like to do. My final goal is more like design a form in xaml and then print it with my data.

Update

I will read this post more carefully. At a first try calling Measure, Arrange, and UpdateLayout on the user control seem promising for my goal.

Community
  • 1
  • 1
Filippo
  • 1,123
  • 1
  • 11
  • 28
  • Have you verified that your data binding works before attempting to print? – Scott Nimrod Dec 31 '15 at 12:13
  • Verified ! Something goes better after calling **updateLayout()** but I still have troubles if I have a ListView with a data- binding on itemsource. – Filippo Dec 31 '15 at 12:28

0 Answers0