View model (the actual view model is a decendant of this one)
public abstract class AstaViewModel : NavigationAwareViewModelBase, IRegionMemberLifetime {
private PrintData _printData;
public PrintData PrintData {
get { return this._printData }
set { SetProperty(ref _printData, value); }
}
...
}
Print data
public class PrintData : INotifyPropertyChanged {
private string _companyName;
public string CompanyName {
get { return this._companyName }
set {
if (this._companyName.Equals(value)) { return; }
this._companyName = value;
OnPropertyChanged();
}
}
}
What am I doing wrong? I had issues with data binding in DataTemplates in the past where I had to set the binding source. Might this be an issue here, too? Can’t see anything about that in the introduction document though.
2. Horizontal alignment
I actually have two elements in my footer, which are supposed to be aligned one on the left and the other on the right, so the footer stretches across the whole page. It doesn’t. It’s always centered and only takes up as much space as the content requires.
I assumed from your description that Diagram.Model is an instance of AstaViewModel. If that’s not the case, you can adapt the binding to fit your environment.
No, we are actually using Prism with MVVM for WPF with AstaViewModel being the view model, that is, it is a decendant of BindableBase, the view bound prism class.
This AstaViewModel contains a Diagram property to which the Diagram in the Xaml code is bound to. And that Diagram’s Model is an object of class AstaData.
I will try to outsource the PrintData into the AstaData class and see whether this solves the problem.
If I replace the SpotPanel with a Grid the SpotPanel.Spot and SpotPanel.Alignment won’t work anymore. The footer gets drawn into the upper left corner of the page right onto the diagram.
Can’t I set the SpotPanel’s width? How would I do the binding? Setting Width="{Binding Path=PageInfo.Viewport}" doesn’t do anything, neither on a grid nor on the SpotPanel, so I wonder if this is correct.
Forget about GoXam and just implement some XAML that does what you want, except that the overall height and width of the Grid is determined by the PageInfo.Viewport.
I don’t know about automatically centering. Would you only want to do that if everything fit on one page, not if it requires multiple pages?
I suppose you could calculate whether the bounds would fit within the page, and if so, you could increase the Margin accordingly. You’ll need to experiment to see if that might work.
The “Full…” PageOptions choices control whether to occupy the whole page of the last row and last column of pages. That includes when there’s only one page to print.
Setting the PrintManager.Scale to NaN or zero causes printing to automatically scale everything to fit in one page.