Reputation: 8918
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.
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
<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?
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.
As always, thanks to the StackOverflow community for any help. :)
Upvotes: 4
Views: 2361
Reputation: 39500
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.
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.
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:
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.
Upvotes: 5