Click here to Skip to main content
15,889,834 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
<pre lang="vb"><pre lang="vb">
Hi,
I am using Visual Studio 2008, VB9. I have created a FlowDocument in XAML that, when it is run, requires VB code behind to fill in answers to questions I have hard coded with XAML in the FlowDocument. For instance, the FlowDocument displays a list of question and I want those answers to that questions inserted at the end of each question by the code behind. To give you an overall picture of what I am trying to do, I will do a calculation that will include a bunch of questions as well as math, save it to a text file and then I want to read the file and fill in the FlowDocument with the answers. I am just a casual programmer (dabbler maybe more accurate) and I don't know anything about databases. I was hoping to just read a text file instead of a database to hold the stored information if that is possible.

Can someone direct me to a source that describes how I can do this?

Thanks,
quicksun
Posted

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:
XML
<FlowDocument Name="myFlowDocument" >
  <!-- you can have some more XAML code here -->
</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
 
Share this answer
 
v5
Thanks Sergey for your reply. It looks like I need to do far more research than I have done so far it understand the connection between the XAML code and the code behind as it pertains to FlowDocuments. If you know of a good paper or article that gives an example of how to creates FlowDocuments I would like to be directed to it.

Thanks again,

quicksun
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900