zoukankan      html  css  js  c++  java
  • WPF使用其他命名空间中的类型

    为使用未在WPF命名空间中定义的类,需要把.net命名空间映射 到一个XML命名空间

    XAML有一个特殊的语法可用于完成这一工作。

    语法:

    xmlns:prefix="clr-namespace:Namespace;assembly=AssemblyName"

    prefix:是希望在XAML标记中用于指示命名空间的XML前缀。例如,XAML语言使用的x前缀。通常情况下,使用.net中其他的类型,前缀使用sys,而使用当前项目中的类型,前缀会使用local命名。

    Namespace:是完全限定的.net命名空间的名称。

    AssemblyName:是声明类型的程序集,没有.dll扩展名。这个程序集必须在项目中引用。如果希望使用项目程序集,则可以忽略这一部分。

    实例:


    <Window x:Class="MyWPF._2_4使用其他命名空间中的类型"
            xmlns
    ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x
    ="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:sys
    ="clr-namespace:System;assembly=mscorlib"
            Title
    ="_2_4使用其他命名空间中的类型" Height="300" Width="300">
        <Grid>
            <ListBox>
                <ListBoxItem>
                    <sys:DateTime>10/13/2010 4:30</sys:DateTime>
                </ListBoxItem>
                <ListBoxItem>
                    <sys:DateTime>10/13/2010 4:30</sys:DateTime>
                </ListBoxItem>
                <ListBoxItem>
                    <sys:DateTime>10/13/2010 4:30</sys:DateTime>
                </ListBoxItem>
                <ListBoxItem>
                    <sys:DateTime>10/13/2010 4:30</sys:DateTime>
                </ListBoxItem>
            </ListBox>
        </Grid>
    </Window>
  • 相关阅读:
    归并两路有序链表
    [转]两种高性能I/O设计模式(Reactor/Proactor)的比较
    linux 静态库使用经验
    系统性能调优经验
    编译-O 选项对性能提升作用
    [转]Linux shell中的那些小把戏
    shell函数传递带空格的参数
    标题清洗引发的算法(两个字符串的最长公共子串)
    正则表达式之Matcher类中group方法
    ConcurrentHashMap JDK 1.6 源码分析
  • 原文地址:https://www.cnblogs.com/zhuiyi/p/2691675.html
Copyright © 2011-2022 走看看