It seems that not all bindings should be evaluated when printing. For example, in the code below, only the first button has content = "100", other buttons have content = "0".
var doc = new XpsDocument("test.xps",FileAccess.Write); var writer = XpsDocument.CreateXpsDocumentWriter(doc); var collator = writer.CreateVisualsCollator(); collator.BeginBatchWrite(); for (int i = 0; i < 3; i++) { var button = new Button(); button.SetBinding(ContentControl.ContentProperty, new Binding { RelativeSource = new RelativeSource(RelativeSourceMode.Self), Path = new PropertyPath("ActualWidth") }); button.Measure(new Size(100, 100)); button.Arrange(new Rect(0, 0, 100, 100)); button.Width = 100; button.Height = 100; collator.Write(button); } collator.EndBatchWrite(); doc.Close();
Is there a workaround?
For example, is there a way to force the binding to evaluate?
source share