如何将XAML FlowDocument与VB9代码连接起来。 [英] How do I connect a XAML FlowDocument with VB9 code behind.

查看:79
本文介绍了如何将XAML FlowDocument与VB9代码连接起来。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<pre lang="vb"><pre lang="vb">



我使用的是Visual Studio 2008,VB9。我在XAML中创建了一个FlowDocument,当它运行时,需要后面的VB代码来填写我在FlowDocument中用XAML硬编码的问题的答案。例如,FlowDocument显示一个问题列表,我希望通过后面的代码在每个问题的末尾插入那些问题的答案。为了让您全面了解我想要做的事情,我将进行计算,其中包括一堆问题以及数学,将其保存到文本文件然后我想要读取文件并填写FlowDocument答案。我只是一个休闲的程序员(dabbler可能更准确),我对数据库一无所知。如果可能的话,我希望只是阅读一个文本文件而不是数据库来保存存储的信息。



有人可以指导我找一个描述我的信息来源可以这样做吗?



谢谢,

quicksun

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

推荐答案

这个问题很难理解你的困惑在哪里。可能这只是对XAML原则上的一般理解。



首先,看看这个:

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" >
  <!-- you can have some more XAML code here -->
</FlowDocument>





基本上,在构建过程中,所有XAML代码(窗口,页面,用户控件)都被编译成一些VB.NET( C#,C ++ / CLI)临时生成和编译的代码。在他看来,你只处理代码背后,而不是XAML。默认情况下,所有对象都是匿名创建的,也就是说,您没有任何窗口类成员可以访问它们。 UI元素的很大一部分不需要您的代码或任何其他代码的任何其他代码,除了初始化它们的代码,这些代码已经自动生成。因此,要告诉XAML生成访问UI元素的字段,请使用 Name XML属性。然后,您可以使用字段 myFlowDocument 访问流文档(在初始化之后)。



(更多一般方法是使用 x:Name 属性,这将是访问您自己类型的实例所必需的。请参阅:

http://msdn.microsoft.com/en-us/library/cc189028%28VS.95 %29.aspx [ ^ ]。)



使用此引用的代码应该是windows(页面,用户控件)类中的代码。构建生成两个部分的类,一个给你,可以编辑,另一个部分不被视为源代码的一部分,它被放置到项目的子目录obj。看看它并了解它的用途是很有用的。



-SA



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


谢谢谢尔盖的回复。看起来我需要做的研究远远超过我迄今为止所做的研究,它理解了XAML代码与后面的代码之间的关系,因为它与FlowDocuments有关。如果您知道一篇好的论文或文章,提供了如何创建FlowDocuments的示例,我希望得到它。



再次感谢,



quicksun
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


这篇关于如何将XAML FlowDocument与VB9代码连接起来。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆