XamlReader动态使用xaml
2015-10-17 09:42
162 查看
xamlload先在xaml做出一个grid,命名xgrid
用和前面写
<script type="text/javascript"> $(function () { $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('<ul/>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('<li/>').text(i)); }; $numbering.fadeIn(1700); }); }); </script>
版权声明:本文为博主原创文章,未经博主允许不得转载。
<Page x:Class="xamlload.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:xamlload" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid x:Name="xgrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Click="button_Click"/> </Grid> </Page>
用和前面写
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Click="button_Click"/>但是位置不一样的按钮
private void button_Click(object sender , RoutedEventArgs e) { string usingXaml = " xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" "; string contentXaml = "<Button Content=\"Button\" HorizontalAlignment=\"Left\" VerticalAlignment=\"Top\""; string marginXaml= "Margin=\"10,50,0,0\"/>"; Button b = XamlReader.Load(contentXaml+usingXaml + marginXaml) as Button; xgrid.Children.Add(b); }
<script type="text/javascript"> $(function () { $('pre.prettyprint code').each(function () { var lines = $(this).text().split('\n').length; var $numbering = $('<ul/>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('<li/>').text(i)); }; $numbering.fadeIn(1700); }); }); </script>
版权声明:本文为博主原创文章,未经博主允许不得转载。
相关文章推荐
- 面试题(多线程)
- excel教学_灵活运用Excel建立有规律的数据库
- 文件编码格式问题
- Linux 在一个命令行上执行多个命令
- hadoop nameNode 无法启动
- matlab操作
- unix Learning
- css兼容问题
- pd的django To Do List教程-----3:模板的建立
- UITableViewCell的背景设置
- qt关闭窗口实现逐渐消失代码
- Nginx得知——Hello World模
- POJ2524
- 基于浏览器首选语言的springmvc和freemarker国际化配置的实现
- RedHat Linux KVM安装配置
- CDN 技术浅析
- 快速排序的递归实现
- 操作
- 非阻塞式通信详解
- 1083 Moving Tables