I'm BRAND NEW to the whole C#/WPF thing. I have a decent understanding of the concept of the WPF layering and it is a very nice tool. What I am running into, however, is that VS and the like try to make things very hands-off as far as the underlying code.
我是整个C#/ WPF的新手。我对WPF分层的概念有一个很好的理解,它是一个非常好的工具。然而,我遇到的是VS等等试图让事情在底层代码中非常轻松。
When firing up a brand new WPF application in VS C# Express 2008, there are two immediately visible source files: App.xaml
and Window1.xaml
. This is all fine and dandy, but the only place I see any significance of where things start is the line in App.xaml
that says
在VS C#Express 2008中启动一个全新的WPF应用程序时,有两个立即可见的源文件:App.xaml和Window1.xaml。这一切都很好,花花公子,但我认为事情开始的唯一地方的唯一地方是App.xaml中的行说
<Application x:Class="SomeName.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml">
Looking into the class name of SomeName.App
, I'm guessing that extending Application
signifies that as where to start, but how does the application actually know that?
查看SomeName.App的类名,我猜测扩展Application表示从哪里开始,但应用程序实际上是如何知道的?
I am quite familiar with Java, so if it makes things easier to explain that way, please do. I like to understand things at the lowest level possible (without getting into machine code), so please help me get a bit deeper into the inner workings of C# and the WPF.
我对Java非常熟悉,所以如果这样可以更容易解释,请这样做。我喜欢尽可能低级地理解事物(没有进入机器代码),所以请帮助我深入了解C#和WPF的内部工作原理。
As always, thanks to the * community for any help. :)
一如既往,感谢*社区的任何帮助。 :)
1 个解决方案
#1
5
The concept you probably need to understand is that the tool-chain generates code from XAML files, which gives 'code-like' behaviour to the declarative XAML.
您可能需要理解的概念是工具链从XAML文件生成代码,这会为声明性XAML提供“类似代码”的行为。
But WPF is pretty complicated and not much like anything else, and a book might be useful - personally I think the Adam Nathan WPF book is excellent, and will cover this "general understanding of the concepts" stuff much better than the Internet, IMO.
但WPF非常复杂,并不像其他任何东西,并且一本书可能是有用的 - 我个人认为Adam Nathan WPF书非常出色,并且将比互联网,IMO更好地涵盖这种“概念的一般理解”。
The generated app file will probably be called app.g.cs, and will be in one of the intermediate file directories - have a look in there to see the actual startup code - among other things, you'll find something like:
生成的应用程序文件可能会被称为app.g.cs,并且将位于其中一个中间文件目录中 - 查看其中的实际启动代码 - 除此之外,您还可以找到以下内容:
public static void Main() {
MyAppName.App app = new MyAppName.App();
app.InitializeComponent();
app.Run();
}
at which point it may start to make more sense.
在这一点上,它可能开始变得更有意义。
In fact, you can write all that startup code yourself if you don't like the declarative route.
实际上,如果您不喜欢声明性路由,则可以自己编写所有启动代码。
#1
5
The concept you probably need to understand is that the tool-chain generates code from XAML files, which gives 'code-like' behaviour to the declarative XAML.
您可能需要理解的概念是工具链从XAML文件生成代码,这会为声明性XAML提供“类似代码”的行为。
But WPF is pretty complicated and not much like anything else, and a book might be useful - personally I think the Adam Nathan WPF book is excellent, and will cover this "general understanding of the concepts" stuff much better than the Internet, IMO.
但WPF非常复杂,并不像其他任何东西,并且一本书可能是有用的 - 我个人认为Adam Nathan WPF书非常出色,并且将比互联网,IMO更好地涵盖这种“概念的一般理解”。
The generated app file will probably be called app.g.cs, and will be in one of the intermediate file directories - have a look in there to see the actual startup code - among other things, you'll find something like:
生成的应用程序文件可能会被称为app.g.cs,并且将位于其中一个中间文件目录中 - 查看其中的实际启动代码 - 除此之外,您还可以找到以下内容:
public static void Main() {
MyAppName.App app = new MyAppName.App();
app.InitializeComponent();
app.Run();
}
at which point it may start to make more sense.
在这一点上,它可能开始变得更有意义。
In fact, you can write all that startup code yourself if you don't like the declarative route.
实际上,如果您不喜欢声明性路由,则可以自己编写所有启动代码。