高防服务器租用 请联系:锐辉网络--小敏 :2853898501 电话: 同号
锐辉网络科技有限公司 官网:
xamlload先在xaml做出一个grid,命名xgrid
<Page
x:Class="xamlload.MainPage"
xmlns=""
xmlns:x=""
xmlns:local="using:xamlload"
xmlns:d=""
xmlns:mc=""
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=\"\" xmlns:x=\"\" ";
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);