zoukankan      html  css  js  c++  java
  • XamlReader 动态加载XAML

    XAML:

    <Grid  xmlns:x="http://schemas.microsoft.com/client/2006" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    	<Button Content="子窗口按钮" HorizontalAlignment="Left" Margin="112,98,0,0" VerticalAlignment="Top" />
    	<Label Content="Label" HorizontalAlignment="Left" Margin="112,169,0,0" VerticalAlignment="Top"/>
    </Grid>
    

    CS:

    using (FileStream s = new FileStream(@"C:\Users\Lin.net\Desktop\WpfApplication1\Xaml\Test.xaml", FileMode.Open))
                {
                    Grid grid = XamlReader.Load(s) as Grid;
                    Window win = new Window1();
                    win.Content = grid;
                    win.ShowDialog();
                }
    

    注意:
    xmlns:x="http://schemas.microsoft.com/client/2006"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    以上两个命名空间必须加入到XAML中间(WPF).Silverlight的命名空间有点区别.

  • 相关阅读:
    MongoDB 与 MySQL 性能比较
    PySpider简易教程
    使用redis有什么缺点
    禅道
    Shell02
    Shell01
    性能测试06
    性能测试05
    性能测试04
    性能测试03
  • 原文地址:https://www.cnblogs.com/answercard/p/2932479.html
Copyright © 2011-2022 走看看