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