How to best learn WPF XAML element positioning

Nicholas Piazza 541 Reputation points
2021-01-21T17:34:33.057+00:00

I'm trying to learn XAML for WPF and UWP applications, but the positioning of elements does not appear very intuitive. In Windows Forms, using C#, I know how to create a form that contains a MenuStrip followed by a Panel of some sort, followed by a StatusStrip, but in XAML, for example, when I try to place a DockPanel containing menu items and a StatusBar inside a <Window></Window> element, I get the compiler warning "The type 'Window' does not support direct content." What is the best documentation for learning where to position different XAML elements?

Developer technologies Universal Windows Platform (UWP)
0 comments No comments
{count} votes

Accepted answer
  1. Yan Gu - MSFT 2,676 Reputation points
    2021-01-22T03:07:16.23+00:00

    Hello,

    Welcome to Microsoft Q&A.

    For XAML in UWP, you could refer to the XAML platform which contains XAML overview, and Design and code Windows apps which contains multiple parts such as Design basics, Layout, Controls and so on.

    When you create a Blank App(UWP), you will see the MainPage.xaml file which auto contains the Page element. You could add a panel such as Grid, StackPanel(referring to the document) within the Page element as the root element. Then add various controls into a panel referring to document about Controls.

    If you want a complete view of a xaml file, you could download the official samples to your local machine and open a sample in the Samples folder with Visual Studio. Or, you could download the XAML Controls Gallery from Windows Store to view various xaml elements and their effects.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.