zoukankan      html  css  js  c++  java
  • XamlReader动态使用xaml

    xamlload先在xaml做出一个grid,命名xgrid

    <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);
            }
  • 相关阅读:
    P1064 金明的预算方案
    P1062 数列
    P2258 子矩阵
    P1095 守望者的逃离
    P1201 [USACO1.1]贪婪的送礼者Greedy Gift Givers
    P1203 [USACO1.1]坏掉的项链Broken Necklace
    P1478 陶陶摘苹果(升级版)
    P2485 [SDOI2011]计算器
    逆元模板
    CloudStack 物理网络架构
  • 原文地址:https://www.cnblogs.com/lindexi/p/12087737.html
Copyright © 2011-2022 走看看