Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,710 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In the constructor of my LedgerPage
, I've this:
Page = new FixedPage() {
Width = PageSize.Width,
Height = PageSize.Height,
Margin = new Thickness(margin),
Children = { header, content, footer }
};
and after some property change, I call measure and this is what I've to position items in the Page:
void measure() {
var availableSize = new Size(PageSize.Width - 2 * margin, PageSize.Height - 2 * margin);
...
double y = 0;
foreach (FrameworkElement item in Page.Children) {
item.Width = availableSize.Width;
item.Measure(availableSize);
item.Arrange(new Rect(new Point(margin, y), item.DesiredSize));
y += item.DesiredSize.Height;
}
...
}
BUT it positions all three items in same place so they overlap:
In the previous version of this app, I'd one Grid
as the Children of Page and in that I put header, content and footer. Now, I want to get rid of that and position each item in the FixedPage, how to do that?
This was helpful, all that I needed was FixedPage.SetTop(...):
foreach (FrameworkElement item in Page.Children) {
item.Width = availableSize.Width;
item.Measure(availableSize);
FixedPage.SetTop(item, y);
y += item.DesiredSize.Height;
}
I don't have to call Measure/Arrange/UpdateLayout on the Page.