- Mastering Visual Studio 2017
- Kunal Chowdhury
- 77字
- 2021-07-15 17:26:43
Working with inline code in XAML pages
You can write inline programming code (C# or VB.NET) within the XAML page, using the x:Code directive and must be surrounded by <![CDATA[...]]> to escape the contents for XML. This can interact within the same XAML page:
<Window x:Class="MyWpfApplication.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Main Window" Height="350" Width="525"> <Grid> <Button Click="Button_Click" Content="Click Here" /> <x:Code> <![CDATA[ void Button_Click(object sender, RoutedEventArgs e) { // event implementation } ]]> </x:Code> </Grid> </Window>
Try to avoid using the inline code in the XAML page, as it violates the separation between the designer and the code behind. Also, other language-specific programming features are not supported in inline coding.
推薦閱讀
- Learning RabbitMQ
- 營銷數據科學:用R和Python進行預測分析的建模技術
- 數據結構簡明教程(第2版)微課版
- PHP網絡編程學習筆記
- Groovy for Domain:specific Languages(Second Edition)
- Podman實戰
- Securing WebLogic Server 12c
- Linux Device Drivers Development
- Web前端應用開發技術
- Hadoop 2.X HDFS源碼剖析
- Android Sensor Programming By Example
- Instant GLEW
- VMware vSphere 5.5 Cookbook
- Node.js Web Development
- Kotlin入門與實戰