1.
XAML doesn’t allow us to split the content property. It should be continuous.
For example the following is illegal and will not compile.
<Button>
<Button.Content>Hello</Button.content> <Button.content>World<button.content>
</Button>
2.
XAML is case sensitive. All the Object elements, Property Elements and attribute names are case sensitive.
Values of the attributes are not always case sensitve. For example
<button content="HelloWorld" background="green"/>
It depends upon the type-converter behaviour associated with the property that takes the value. In the above example Background=”Green” or “green” is OK
3.
XAML ignores all nonsignificant whitespaces. Spaces will be considered if it’s in content property.
<button content=" HelloWorld" margin="26,59,0,0" background=" aqua " width="90" verticalalignment="Top" horizontalalignment="Left" height="21"/>
If you notice the above example the space surrounding “aqua” will be trimmed whereas space in front of “ Helloworld” will be considered.
4.
XAML files must have only one root element. It should be a well formed XML file and a valid XAML file
How to write inline coding in XAML:
We can write the code either in code behind page or inline. Code behind is recommended as definitely it’s advantageous.
To write an inline code in XAML we have to use x:Code directive along with
<button content="Hello" click="SayHello">
</button>
<x:code>
<![CDATA[
void SayHello (object sender, RoutedEventArgs e)
{
MessageBox.Show("Hello");
SayMorning();
}
void SayMorning (){
MessageBox.Show("Good Morning");
}
]]>
</x:code>
No comments:
Post a Comment