WPF FAQ - XAMLPAD

What is the use of x:code ?

x:Code is a directive element defined in XAML. An x:Code directive element can contain inline programming code. The code that is defined inline can interact with the XAML on the same page. The following example illustrates inline C# code. Notice that the code is inside the x:Code element and that the code must be surrounded by <CDATA[…]]> to escape the contents for XML, so that an XAML processor (interpreting either the XAML schema or the WPF schema) will not try to interpret the contents literally as XML.

[XAML]

<Page
  xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
  xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
  x:Class='MyNamespace.MyCanvasCodeInline'
>
  <Button Name='button1' Click='Clicked'>Click Me!</Button>
  <x:Code><![CDATA[
    void Clicked(object sender, RoutedEventArgs e)
    {
        button1.Content = 'Hello World';
    }
  ]]></x:Code>
</Page>
Permalink
Can we see the output of an XAML using XAMLPAD ?

Yes. The output of an XAML file can be viewed using the ’Refresh’ button or by pressing ’F5’ button. When ’Refresh’ button is clicked, XAMLPAD parses and renders the content and displays the output.

Permalink
Does XAMLPAD support custom controls ?

Custom controls can be added by adding the dlls to the XAMLPAD using the Load Menu item in the File Menu (available in XAMLPAD V3.0).

Permalink
What is XAMLPAD ?

XAMLPAD is a tool used to edit XAML files. It also displays the visual tree and properties of a control.

Permalink