Hello, i want to print report pragmaticaly from silverlight... i already have code:
private void OnPrintButtonClick(object sender, RoutedEventArgs e)
{
PrintDocument pd = new PrintDocument();
Collection<Canvas> pagesList = new Collection<Canvas>();
Model.PageRoot.UpdateLayout();
pagesList.Add((Canvas)Model.PageRoot);
while (Model.PageNumber < Model.PageCount)
{
Model.MoveToNextPageCommand.Execute(null);
Model.PageRoot.UpdateLayout();
pagesList.Add((Canvas)Model.PageRoot);
}
int index = 0;
pd.PrintPage += (s, arg) =>
{
if (index >= pagesList.Count)
{
arg.HasMorePages = false;
return;
}
arg.PageVisual = pagesList.ElementAt(index);
arg.HasMorePages = true;
index++;
};
pd.Print("");
}
but when i use Model.MoveToNextPageCommand.Execute(null); PageRoot is not updated and i have the same page each time... can you help me? how can i go through pages and collect data in images array for print them next? what should i do to update pageroot?
private void OnPrintButtonClick(object sender, RoutedEventArgs e)
{
PrintDocument pd = new PrintDocument();
Collection<Canvas> pagesList = new Collection<Canvas>();
Model.PageRoot.UpdateLayout();
pagesList.Add((Canvas)Model.PageRoot);
while (Model.PageNumber < Model.PageCount)
{
Model.MoveToNextPageCommand.Execute(null);
Model.PageRoot.UpdateLayout();
pagesList.Add((Canvas)Model.PageRoot);
}
int index = 0;
pd.PrintPage += (s, arg) =>
{
if (index >= pagesList.Count)
{
arg.HasMorePages = false;
return;
}
arg.PageVisual = pagesList.ElementAt(index);
arg.HasMorePages = true;
index++;
};
pd.Print("");
}
but when i use Model.MoveToNextPageCommand.Execute(null); PageRoot is not updated and i have the same page each time... can you help me? how can i go through pages and collect data in images array for print them next? what should i do to update pageroot?