Inline function within XAML

Most of the time, the event in XAML is assigned to a codebehind function
Example:
*.xaml
<button click="OnBtnClicked" content="Click Me" height="30" name="btn" width="80"></button>
*.cs
void OnBtnClicked(object sender, RoutedEventArgs e)
{
        btn.Content = "Thank you";
}


Another way is to use inline code in the XAML file by using <x:code> element.
<button click="OnBtnClicked" content="Click Me" height="30" name="btn" width="80">
  <x:code>
    <![CDATA[
      void OnBtnClicked(object sender, RoutedEventArgs e)
      {
        btn.Content = "Thank you";
      }
    ]]>
  </x:code>
</button>

1 comments:

Santosh said...

Hi,
Last many days I am searching some good article and I am very glad to find your article. This is very essential and informative information for me. I would like to say your post is superb and relevant my topics.
Thanks

Post a Comment

top