Lester's WPF\SL Blog

Simple, Easy & Beautiful

Xaml Inline coding

Xaml Inline coding

  • Comments 2

One interesting aspect is Xaml is that you can have inline code.... the syntax is as below

<Window x:Class="WindowsApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="Window1_Loaded">
<
x:Code>
      <![CDATA[
              void Window1_Loaded(object sender, RoutedEventArgs e)
              {
                   this.Title="yoohoo";
                  
TextBox tb = new TextBox();
                   tb.Text="hello world";
                   this.Content=tb;
               }
      
]]>
</
x:Code>
</
Window>

 

 

  • Seems like a step back to me. How is this better than having a Form object of which you set its properties? The whole XML fetish with everythign seems a bit strange to me.

  • I bet the designers did give this a thought and incorporated the best features in Xaml...

    Also, XML is probably the most popular and widespread - So IMHO its likely that any new markup lang will have to follow similar patterns. ;)

Page 1 of 1 (2 items)