I want to get a XAML specified interface on the screen so I can learn WPF. But I do not want to start from a visual studio project which has all the wire-up already done. I wan't the c# "hello world" equavalent of drawing a window specified in a xaml file on the screen from the "main()" function.
So how do I wire-up a XAML file to an object and draw it on the screen from a console app ? Please wire-up a simple event as well. Say a "hello world" button (specified in xaml), that when pressed makes the console print "hello world". I'd prefer to see the delegate function in the following ways.
- The logic as inline c# in XAML.
- The logic specified in the same file as the "main()" method, as a free function (edit : oh wait c# doesn't have free functions, well a delegate of some sort that isn't code behind).
- The logic as a member function of an object, where I believe the object to be the codebehind of the XAML (assuming ofcourse this way of mapping between xaml and c# objects is possible).
Additionally : This answer shows the ui runloop taking over the main thread, is there any sugar to create a new thread for the app so it doesn't block the callee ?
If your wondering why I am asking this question, or why I want to learn WPF this way. I want to trigger ad-hoc UI elements from within a plugin that has no other means of displaying information.
For those that find this question too vague, here is an example of xaml
<Canvas xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBlock>Hello World!</TextBlock>
</Canvas>
The main app in this question is a console c# app, the XAML file represents a form with a single button, pressing the button prints "hello world" to the console. And I want to see the different ways of wiring up the button to my code, I do not understand how I could be clearer.