zoukankan      html  css  js  c++  java
  • 设计时特性

    d:DataContext="{d:DesignInstance viewModel:ContactViewModel}"

    这样再xaml里面写binding 能联想出来

     http://technet.microsoft.com/zh-CN/library/ee839627(v=vs.100)

    WPF 设计器提供下列设计时特性。

     

    设计时特性

    说明

    示例用法

    d:DesignHeight

    在设计时指定根元素的高度,该高度与运行时的高度无关。在您单击根大小标记 () 时自动增加。

    <Window x:Class="DesignDataDemo.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:DesignDataDemo"
            Title="MainWindow" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="350" d:DesignWidth="525" SizeToContent="WidthAndHeight">
    
    
    

    d:DesignWidth

    在设计时指定根元素的宽度,该宽度与运行时的宽度无关。在您单击根大小标记 () 时自动增加。

    <Window x:Class="DesignDataDemo.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:DesignDataDemo"
            Title="MainWindow" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="350" d:DesignWidth="525" SizeToContent="WidthAndHeight">
    
    
    

    d:DataContext

    为控件及其子控件指定设计时数据上下文。一个常见模式是:在 XAML 视图中声明控件绑定并设置用来在运行时填充绑定的 DataContext如果使用此模式,则可以设置 d:DataContext,以便设计器能够识别您所用类型的形状。这使您能够使用数据绑定生成器,在“设计”视图中创建绑定。有关更多信息,请参见演练:使用 WPF 设计器创建数据绑定

    <Grid d:DataContext="{d:DesignInstance Type=local:Customer}" Name="_grid">
    
    
    

    d:DesignInstance

    用作 d:DataContextd:DesignSource 声明的一部分。指定要用作数据源而且要绑定到设计器中控件的类型。该类型在 XAML 中不一定是可创建的。有关更多信息,请参见演练:在设计器中使用 DesignInstance 绑定到数据

    <Grid d:DataContext="{d:DesignInstance Type=local:Customer}" Name="_grid">
    
    
    

    d:DesignData

    用作 d:DataContextd:DesignSource 声明的一部分。指定一个 XAML 文件,其中包含要在设计时使用的示例数据。使用“DesignData”“DesignDataWithDesignTimeCreatableTypes”生成操作可以将示例数据与您的项目集成。可以为只读属性赋值。有关更多信息,请参见演练:使用 WPF 设计器中的示例数据

    <StackPanel d:DataContext="{d:DesignData Source=./DesignData/SampleCustomer.xaml}" Grid.Row="0"></StackPanel>
    
    
    

    d:DesignSource

    CollectionViewSource 指定设计时数据源。这使设计器能够识别您所用类型的形状。这样便可使用数据绑定生成器创建绑定。

     
    <CollectionViewSource x:Key="CustomerViewSource" d:DesignSource="{d:DesignInstance local:Customer, CreateList=True}" /> 
    

    d:IsDesignTimeCreatable

    d:DesignInstance 标记扩展中,指定根据您的类型创建设计实例,而非设计器生成的替代类型。

     
    <Grid d:DataContext="{d:DesignInstance local:Customer, IsDesignTimeCreatable=True}">
    

    d:CreateList

    d:DesignInstance 标记扩展中,指定设计实例是指定类型的列表。

     
    <CollectionViewSource x:Key="CustomerViewSource" d:DesignSource="{d:DesignInstance local:Customer, CreateList=True}" />
    

    d:Type

    d:DesignInstance 标记扩展中,指定要创建的类型。使用 d:IsDesignTimeCreatable 可以指定是创建某一实例或您的类型还是设计器生成的替代类型。

     
    <CollectionViewSource x:Key="CustomerViewSource" d:DesignSource="{d:DesignInstance Type=local:Customer, CreateList=True}" />
    

    可以通过 http://schemas.microsoft.com/expression/blend/2008 命名空间访问设计时特性。当您在“设计”视图中单击 MainWindow 右下角处的根大小标记 () 时,系统会自动映射命名空间。

    若要启用 d:DesignData,应当针对包含示例数据的 XAML 文件设置生成操作。下表描述了生成操作。有关更多信息,请参见演练:使用 WPF 设计器中的示例数据

     

    生成操作

    说明

    DesignData

    在示例数据类型无法创建或具有您要为示例数据值定义的只读属性时,使用此生成操作。WPF 和 Silverlight 设计器创建与业务对象类型具有相同属性的替换类型。您的类型不一定是可创建的。这消除了工厂方法、抽象类型和数据库连接的复杂性。可以为只读属性赋值。

    DesignDataWithDesignTimeCreatableTypes

    在可通过使用其默认的空构造函数创建示例数据类型时,使用此生成操作。WPF and Silverlight Designer 可创建您在示例数据文件中定义的类型的实例。您所用的类型在 XAML 中必须是可创建的。

  • 相关阅读:
    kolla多节点部署openstack
    归并排序
    gitlab ci/cd
    微信、支付宝个人收款码不能用于经营收款 z
    微信小程序弹出和隐藏遮罩层动画以及五星评分
    centos7 安装 nginx
    netty+websocket模式下token身份验证遇到的问题
    windows 截图 win+shift+s
    linux下 "chmod 777" 中777这个数字是怎么出来的
    nginx四层转发,访问内网mysql数据库
  • 原文地址:https://www.cnblogs.com/aoldman/p/2964624.html
Copyright © 2011-2022 走看看