It's hard to understand the question and where your confusion is. Probably, this is just general understanding of what XAML does in principle.
First, look at this:
<FlowDocument Name="myFlowDocument" >
</FlowDocument>
Essentially, during build, all XAML code (windows, pages, user controls) is compiled into some VB.NET (C#, C++/CLI) code which is temporary generated and compiled. In his sense, you only deal with "code behind", not XAML. By default, all objects are created anonymously, that is, you don't get any window class members to access them. Big part of UI Elements don't need any access from you code, or any other code except the code initializing them, which is already auto-generated. So, to tell XAML to generate the fields to access UI Element, you use the
Name
XML attribute. Then, you can access the flow document (after it is initialized) using the field
myFlowDocument
.
(More general approach is using
x:Name
attribute, which will be required for access of the instances of your own type. Please see:
http://msdn.microsoft.com/en-us/library/cc189028%28VS.95%29.aspx[
^].)
The code using this references should be the code in your windows (page, user control) class. The build generates the class in two parts, one is given to you and can be edited, another part is not considered as the part of source code, it is placed to the sub-directory "obj" of your project. It's useful to look at it and see what it does, for understanding.
—SA