• WPF基础知识


    可以使用XAML创建任何类,必须是友好声明,构造函数没有参数的。

    XAML就是.NET语言的一种表现形式。只是和C#书写格式不一样而已。

    根元素的标记、主窗体标记

    x:class、StartupUri="Window1.xaml"

    一元素,特性

       1、XAML中一个元素可以理解为程序中的一个对象,里面包含对象的类型                 

                      特性(元素的特性):一个对象的Public属性

                      附加特性:解析到附加特性时将执行一个对应的事件。

                                  Grid.SetRow(控件, 行)

       2、程序运行时会自动创建根据XAML中的元素、特性自动创建对象并 设置对象的值。

       3、子元素:

           3.1、内容

           3.2、集合(IList、IDictionary)

           3.3、转换

           对象元素的子元素XAML处理规则

           IList

           IDictionary  

           内容属性

           转换

    二。命名空间

       1、和C#编程环境一样,引用那个对象需要首相将对象的命名空间添加到当前单元、XAML

           也需要添加单元引用,只是格式和C#程序环境有点差别。

           两个通用的命名空间:

           xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation   
           xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml

    2、引用其他命名空间格式:

        xmlns:自定义=“clr-namespace:对象的命名空间;assembly=DLL名称

                如果本程序集可以省去assembly

    三。扩展标记

         1.、应用:设置属性值使用

         2、扩展标记类必须从System.Windows.Markup继承

         3.、使用“{Markup 参数}”

         4、执行:创建“Markup”实例->调用Providevalue过程获取参数中的值。

         5、binding留在以后章节。     

    四。动态加载XAML(XamlReader   XamlWrite)

         XamlReader.Load()//边加载,边解析  XamlWrite.Save(windows)

        动态加载例子:

    隐藏行号 复制代码 这是一段程序代码。
    1. // Get the XAML content from an external file.            
      
    2. FileStream s = new FileStream("Window1.xml", FileMode.Open);
      
    3. DependencyObject rootElement = (DependencyObject)
      
    4.     XamlReader.Load(s);
      
    5. this.Content = rootElement;                       
      
    6. 
      
    7. // Find the control with the appropriate name.
      
    8. //button1 = (Button)LogicalTreeHelper.FindLogicalNode(rootElement, "button1");
      
    9. FrameworkElement frameworkElement = (FrameworkElement)rootElement;
      
    10. button1 = (Button)frameworkElement.FindName("button1");
      
    11. 
      
    12. // Wire up the event handler.
      
    13. button1.Click += new RoutedEventHandler(button1_Click);
      
  • 相关阅读:
    Ext.grid.column.Column主要配置项及示例
    Ext.grid.Panel主要配置及示例
    EF Code First关系规则及配置
    ExtJS4系列目录
    EF Code First数据库连接配置
    ASP.NET MVC系列:ASP.NET MVC简介
    Ext JS下载及配置
    Ext.container.Viewport
    Ext.tab.Panel页签
    ASP.NET MVC系列:Controller/Action
  • 原文地址:https://www.cnblogs.com/SouthAurora/p/1749461.html
Copyright © 2020-2023  润新知