What is x:Code?

 Posted by Ddd on 3/22/2011 | Category: WPF Interview questions | Views: 3793 | Points: 40
Answer:

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.

example:

<Window  x:Class="WpfApplication14jan.Window1"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300" Loaded="Window_Loaded">
<Grid Name="dd">
<Button Name="button1" Click="Clicked">In Line code!</Button>

<x:Code>
<![CDATA[
void Clicked(object sender, RoutedEventArgs e)
{
button1.Content = "WPF Inline Code";
}
]]>
</x:Code>


</Grid>
</Window>


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response