Szerkesztés

Megosztás a következőn keresztül:


FixedPage.SetTop(UIElement, Double) Method

Definition

Sets the distance between the top of an element and the top of its parent Canvas.

public:
 static void SetTop(System::Windows::UIElement ^ element, double length);
public static void SetTop (System.Windows.UIElement element, double length);
static member SetTop : System.Windows.UIElement * double -> unit
Public Shared Sub SetTop (element As UIElement, length As Double)

Parameters

element
UIElement

The element on which to set the top offset.

length
Double

The new distance between the top side of the element and the top side of its parent canvas.

Examples

The following example shows use of the SetTop method.

// --------------------- CreateFifthPageContent -----------------------
/// <summary>
///   Creates the content for the fifth fixed page.</summary>
/// <returns>
///   The page content for the fifth fixed page.</returns>
private PageContent CreateFifthPageContent()
{
    PageContent pageContent = new PageContent();
    FixedPage   fixedPage   = new FixedPage();
    UIElement   visual      = CreateThirdVisual(false);

    FixedPage.SetLeft(visual, 0);
    FixedPage.SetTop(visual, 0);

    double pageWidth = 96 * 8.5;
    double pageHeight = 96 * 11;

    fixedPage.Width = pageWidth;
    fixedPage.Height = pageHeight;

    fixedPage.Children.Add((UIElement)visual);

    Size sz = new Size(8.5 * 96, 11 * 96);
    fixedPage.Measure(sz);
    fixedPage.Arrange(new Rect(new Point(), sz));
    fixedPage.UpdateLayout();

    ((IAddChild)pageContent).AddChild(fixedPage);
    return pageContent;
}// end:CreateFifthPageContent()
' --------------------- CreateFifthPageContent -----------------------
''' <summary>
'''   Creates the content for the fifth fixed page.</summary>
''' <returns>
'''   The page content for the fifth fixed page.</returns>
Private Function CreateFifthPageContent() As PageContent
    Dim pageContent As New PageContent()
    Dim fixedPage As New FixedPage()
    Dim visual As UIElement = CreateThirdVisual(False)

    FixedPage.SetLeft(visual, 0)
    FixedPage.SetTop(visual, 0)

    Dim pageWidth As Double = 96 * 8.5
    Dim pageHeight As Double = 96 * 11

    fixedPage.Width = pageWidth
    fixedPage.Height = pageHeight

    fixedPage.Children.Add(CType(visual, UIElement))

    Dim sz As New Size(8.5 * 96, 11 * 96)
    fixedPage.Measure(sz)
    fixedPage.Arrange(New Rect(New Point(), sz))
    fixedPage.UpdateLayout()

    CType(pageContent, IAddChild).AddChild(fixedPage)
    Return pageContent
End Function ' end:CreateFifthPageContent()

Remarks

The child element's top offset does not affect the size of the parent canvas.

If both a top and bottom offset have been specified on the same element, the top offset takes precedence.

When setting the top offset as a percentage, the percentage value is based on the size of the parent canvas.

Applies to

See also